CDL Modules
bbc_submodules.h
Go to the documentation of this file.
1 
25 /*a Includes */
26 include "csr_interface.h"
27 include "srams.h"
28 include "bbc_micro_types.h"
29 include "framebuffer.h"
30 include "input_devices.h"
31 
32 /*a Modules */
33 /*m bbc_vidproc */
34 extern module bbc_vidproc( clock clk_cpu "Output on real chip in a sense (2MHz out somewhat)",
35  clock clk_2MHz_video "Output on real chip, 2MHz video clock",
36  input bit reset_n "Not present on the chip, but required for the model - power up reset",
37  input bit chip_select_n "Active low chip select",
38  input bit address "Valid with chip select",
39  input bit[8] cpu_data_in "Data in (from CPU) - was combined with pixel_data_in in BBC micro to save pins",
40  input bit[8] pixel_data_in "Data in (from RAM) - was combined with cpu_data_in in BBC micro to save pins",
41  input bit disen "Asserted by CRTC if black output required (e.g. during sync)",
42  input bit invert_n "Asserted (low) if the output should be inverted (post-disen probably)",
43  input bit cursor "Asserted for first character of a cursor",
44  input bit[6] saa5050_red "3 pixels in at 2MHz, red component, from teletext",
45  input bit[6] saa5050_green "3 pixels in at 2MHz, green component, from teletext",
46  input bit[6] saa5050_blue "3 pixels out at 2MHz, blue component, from teletext",
47  output bit crtc_clock_enable "High for 2MHz, toggles for 1MHz - the 'character clock' - used also to determine when the shift register is loaded",
48  output bit[8] red "8 pixels out at 2MHz, red component",
49  output bit[8] green "8 pixels out at 2MHz, green component",
50  output bit[8] blue "8 pixels out at 2MHz, blue component",
51  output t_bbc_pixels_per_clock pixels_valid_per_clock
52  )
53 {
54  timing to rising clock clk_cpu chip_select_n, address, cpu_data_in;
55  timing to rising clock clk_2MHz_video saa5050_red, saa5050_green, saa5050_blue, pixel_data_in;
56  timing to rising clock clk_2MHz_video disen, invert_n, cursor;
57  timing from rising clock clk_2MHz_video crtc_clock_enable;
58  timing from rising clock clk_2MHz_video red, green, blue, pixels_valid_per_clock;
59 
60 }
61 
62 /*m crtc6845 */
63 extern module crtc6845( clock clk_2MHz,
64  clock clk_1MHz "Clock that rises when the 'enable' of the 6845 completes - but a real clock for this model",
65  input bit reset_n,
66  output bit[14] ma "Memory address",
67  output bit[5] ra "Row address",
68  input bit read_not_write "Indicates a read transaction if asserted and chip selected",
69  input bit chip_select_n "Active low chip select",
70  input bit rs "Register select - address line really",
71  input bit[8] data_in "Data in (from CPU)",
72  output bit[8] data_out "Data out (to CPU)",
73  input bit lpstb_n "Light pen strobe",
74  input bit crtc_clock_enable "Not on the real chip - really CLK - the character clock - but this is an enable for clk_2MHz",
75  output bit de,
76  output bit cursor,
77  output bit hsync,
78  output bit vsync
79  )
80 {
81  timing to rising clock clk_1MHz read_not_write, chip_select_n, rs, data_in;
82  timing from rising clock clk_1MHz data_out;
83 
84  timing to rising clock clk_2MHz crtc_clock_enable;
85  timing from rising clock clk_2MHz ma, ra, de, cursor, hsync, vsync;
86 }
87 
88 /*m acia6850 */
89 extern module acia6850( clock clk "Clock that rises when the 'enable' of the 6850 completes - but a real clock for this model",
90  input bit reset_n,
91  input bit read_not_write "Indicates a read transaction if asserted and chip selected",
92  input bit[2] chip_select "Active high chip select",
93  input bit chip_select_n "Active low chip select",
94  input bit address "Changes during phase 1 (phi[0] high) with address to read or write",
95  input bit[8] data_in "Data in (from CPU)",
96  output bit[8] data_out "Read data out (to CPU)",
97  output bit irq_n "Active low interrupt",
98  input bit tx_clk "Clock used for transmit data - must be really about at most quarter the speed of clk",
99  input bit rx_clk "Clock used for receive data - must be really about at most quarter the speed of clk",
100  output bit txd,
101  input bit cts,
102  input bit rxd,
103  output bit rts,
104  input bit dcd
105  )
106 {
107  timing to rising clock clk read_not_write, chip_select, chip_select_n, address, data_in;
108  timing from rising clock clk data_out, irq_n;
109  timing to rising clock clk tx_clk, rx_clk, cts, rxd, dcd;
110  timing from rising clock clk txd, rts;
111  timing comb input read_not_write, chip_select, chip_select_n, address;
112  timing comb output data_out;
113 }
114 
115 /*m bbc_micro_keyboard */
116 extern module bbc_micro_keyboard( clock clk,
117  input bit reset_n,
118  output bit reset_out_n "From the Break key",
119  input bit keyboard_enable_n "Asserted to make keyboard detection operate",
120  input bit[4] column_select "Wired to pa[4;0], and indicates which column of the keyboard matrix to access",
121  input bit[3] row_select "Wired to pa[3;4], and indicates which row of the keyboard matrix to access",
122  output bit key_in_column_pressed "Wired to CA2, asserted if keyboard_enable_n and a key is pressed in the specified column (other than row 0)",
123  output bit selected_key_pressed "Asserted if keyboard_enable_n is asserted and the selected key is pressed",
124  input t_bbc_keyboard bbc_keyboard
125  )
126 {
127  timing to rising clock clk keyboard_enable_n, column_select;
128  timing from rising clock clk reset_out_n, key_in_column_pressed, selected_key_pressed;
129  timing comb input row_select, column_select, keyboard_enable_n;
130  timing comb output selected_key_pressed, key_in_column_pressed;
131  timing to rising clock clk bbc_keyboard;
132 }
133 
134 /*m via6522 */
135 extern module via6522( clock clk "1MHz clock rising when bus cycle finishes",
136  clock clk_io "1MHz clock rising when I/O should be captured - can be antiphase to clk",
137  input bit reset_n,
138  input bit read_not_write "Indicates a read transaction if asserted and chip selected",
139  input bit chip_select "Active high chip select",
140  input bit chip_select_n "Active low chip select",
141  input bit[4] address "Changes during phase 1 (phi[0] high) with address to read or write",
142  input bit[8] data_in "Data in (from CPU)",
143  output bit[8] data_out "Read data out (to CPU)",
144  output bit irq_n "Active low interrupt",
145  input bit ca1 "Port a control 1 in",
146  input bit ca2_in "Port a control 2 in",
147  output bit ca2_out "Port a control 2 out",
148  output bit[8] pa_out "Port a data out",
149  input bit[8] pa_in "Port a data in",
150  input bit cb1 "Port b control 1 in",
151  input bit cb2_in "Port b control 2 in",
152  output bit cb2_out "Port b control 2 out",
153  output bit[8] pb_out "Port b data out",
154  input bit[8] pb_in "Port b data in"
155  )
156 {
157  timing to rising clock clk read_not_write, chip_select, chip_select_n, address, data_in;
158  timing from rising clock clk data_out, irq_n;
159  timing to rising clock clk ca1, ca2_in, pa_in, cb1, cb2_in, pb_in;
160  timing from rising clock clk ca2_out, pa_out, cb2_out, pb_out;
161  timing to rising clock clk_io ca1, ca2_in, pa_in, cb1, cb2_in, pb_in;
162  timing from rising clock clk_io ca2_out, pa_out, cb2_out, pb_out;
163  timing comb input chip_select, chip_select_n, read_not_write, address;
164  timing comb output data_out;
165 }
166 
167 /*m cpu6502 */
168 extern module cpu6502( clock clk "Clock, rising edge is start of phi1, end of phi2 - the phi1/phi2 boundary is not required",
169  input bit reset_n,
170  input bit ready "Stops processor during current instruction. Does not stop a write phase. Address bus reflects current address being read. Stops the phase 2 from happening.",
171  input bit irq_n "Active low interrupt in",
172  input bit nmi_n "Active low non-maskable interrupt in",
173  output bit ba "Goes high during phase 2 if ready was low in phase 1 if read_not_write is 1, to permit someone else to use the memory bus",
174  output bit[16] address "In real 6502, changes during phi 1 with address to read or write",
175  output bit read_not_write "In real 6502, changes during phi 1 with whether to read or write",
176  output bit[8] data_out "In real 6502, valid at end of phi2 with data to write",
177  input bit[8] data_in "Captured at the end of phi2 (rising clock in here)"
178  )
179 {
180  timing to rising clock clk ready, irq_n, nmi_n, data_in;
181  timing from rising clock clk ba, address, read_not_write, data_out;
182 }
183 
184 /*m saa5050 */
185 extern module saa5050( clock clk_2MHz "Supposedly 6MHz pixel clock (TR6), except we use 2MHz and deliver 3 pixels per tick; rising edge should be coincident with clk_1MHz edges",
186  input bit clk_1MHz_enable "Clock enable high for clk_2MHz when the SAA's 1MHz would normally tick",
187  input bit reset_n,
188  input bit superimpose_n "Not implemented",
189  input bit data_n "Serial data in, not implemented",
190  input bit[7] data_in "Parallel data in",
191  input bit dlim "clocks serial data in somehow (datasheet is dreadful...)",
192  input bit glr "General line reset - can be tied to hsync - assert once per line before data comes in",
193  input bit dew "Data entry window - used to determine flashing rate and resets the ROM decoders - can be tied to vsync",
194  input bit crs "Character rounding select - drive high on even interlace fields to enable use of rounded character data (kinda indicates 'half line')",
195  input bit bcs_n "Assert (low) to enable double-height characters (?) ",
196  output bit tlc_n "Asserted (low) when double-height characters occur (?) ",
197  input bit lose "Load output shift register enable - must be low before start of character data in a scanline, rising with (or one tick earlier?) the data; changes off falling F1, rising clk_1MHz",
198  input bit de "Display enable",
199  input bit po "Picture on",
200  output bit[6] red,
201  output bit[6] green,
202  output bit[6] blue,
203  output bit blan,
204  input t_bbc_micro_sram_request host_sram_request "Write only, writes on clk_2MHz rising, acknowledge must be handled by supermodule" )
205 {
206  timing to rising clock clk_2MHz clk_1MHz_enable, data_in, lose;
207  timing to rising clock clk_2MHz host_sram_request;
208  timing from rising clock clk_2MHz red, green, blue;
209 }
210 
211 /*m fdc8271 */
212 extern module fdc8271( clock clk "",
213  input bit reset_n "8271 has an active high reset, but...",
214  input bit chip_select_n "Active low chip select",
215  input bit read_n "Indicates a read transaction if asserted and chip selected",
216  input bit write_n "Indicates a write transaction if asserted and chip selected",
217  input bit[2] address "Address of register being accessed",
218  input bit[8] data_in "Data in (from CPU)",
219  output bit[8] data_out "Read data out (to CPU)",
220  output bit irq_n "Was INT on the 8271, but that means something else now; active low interrupt",
221  output bit data_req "",
222  input bit data_ack_n "",
223  output bit[2] select "drive select",
224  input bit[2] ready "drive ready",
225  output bit fault_reset "",
226  output bit write_enable "High if the drive should write data",
227  output bit seek_step "High if the drive should step",
228  output bit direction "Direction of step",
229  output bit load_head "Enable drive head",
230  output bit low_current "Asserted for track>=43",
231  input bit track_0_n "Asserted low if the selected drive is on track 0",
232  input bit write_protect_n "Asserted low if the selected drive is write-protected",
233  input bit index_n "Asserted low if the selected drive photodiode indicates start of track",
234  output t_bbc_floppy_op bbc_floppy_op "Model drive operation, including write data",
235  input t_bbc_floppy_response bbc_floppy_response "Parallel data read, specific to the model"
236  // fault_n, count_n, plo, write_data, unseparated_data_n, data_window, insync
237  )
238 {
239  timing to rising clock clk chip_select_n, read_n, write_n, address, data_in;
240  timing from rising clock clk data_out, irq_n;
241 
242  timing to rising clock clk data_ack_n;
243  timing from rising clock clk data_req;
244 
245  timing to rising clock clk bbc_floppy_response;
246  timing from rising clock clk bbc_floppy_op;
247 
248  timing comb input data_ack_n, address, read_n, chip_select_n;
249  timing comb output data_out;
250 }
251 
252 /*m bbc_micro_clocking */
253 extern module bbc_micro_clocking( clock clk "4MHz clock in as a minimum",
254  input bit reset_n,
255  input t_bbc_clock_status clock_status,
256  output t_bbc_clock_control clock_control,
257  input t_csr_request csr_request,
258  output t_csr_response csr_response )
259 {
260  timing to rising clock clk clock_status;
261  timing from rising clock clk clock_control;
262  timing to rising clock clk csr_request;
263  timing from rising clock clk csr_response;
264 }
265 
266 /*m bbc_micro_rams */
267 extern module bbc_micro_rams( clock clk "4MHz clock in as a minimum",
268  input bit reset_n,
269  input t_bbc_clock_control clock_control,
270  input t_bbc_micro_sram_request host_sram_request,
271  output t_bbc_micro_sram_response host_sram_response,
272  input t_bbc_display_sram_write display_sram_write,
273  input t_bbc_floppy_sram_request floppy_sram_request,
274  output t_bbc_floppy_sram_response floppy_sram_response,
275  output t_bbc_micro_sram_request bbc_micro_host_sram_request,
276  input t_bbc_micro_sram_response bbc_micro_host_sram_response )
277 {
278  timing to rising clock clk clock_control;
279  timing to rising clock clk host_sram_request, display_sram_write, floppy_sram_request, bbc_micro_host_sram_response;
280  timing from rising clock clk host_sram_response, floppy_sram_response, bbc_micro_host_sram_request;
281 }
282 
283 /*m bbc_micro */
284 extern module bbc_micro( clock clk "Clock at least at '4MHz' - CPU runs at least half of this",
285  input t_bbc_clock_control clock_control,
286  output t_bbc_clock_status clock_status,
287  input bit reset_n,
288  input t_bbc_keyboard keyboard,
289  output t_bbc_display display,
290  output bit keyboard_reset_n,
291  output t_bbc_floppy_op floppy_op,
292  input t_bbc_floppy_response floppy_response,
293  input t_bbc_micro_sram_request host_sram_request,
294  output t_bbc_micro_sram_response host_sram_response )
295 {
296  timing to rising clock clk clock_control, keyboard, floppy_response;
297  timing from rising clock clk clock_status, display, floppy_op;
298 
299  timing to rising clock clk host_sram_request;
300  timing from rising clock clk host_sram_response;
301 }
302 
303 /*m bbc_display_sram */
304 extern module bbc_display_sram( clock clk "Clock running at 2MHz",
305  input bit reset_n,
306  input t_bbc_display display,
307  output t_bbc_display_sram_write sram_write,
308  input t_csr_request csr_request,
309  output t_csr_response csr_response
310  )
311 {
312  timing to rising clock clk display, csr_request;
313  timing from rising clock clk sram_write, csr_response;
314 }
315 
316 /*m bbc_keyboard_csr */
317 extern module bbc_keyboard_csr( clock clk "Clock running at 2MHz",
318  input bit reset_n,
319  output t_bbc_keyboard keyboard,
320  input bit keyboard_reset_n,
321  input t_csr_request csr_request,
322  output t_csr_response csr_response
323  )
324 {
325  timing to rising clock clk keyboard_reset_n, csr_request;
326  timing from rising clock clk keyboard, csr_response;
327 }
328 
329 /*m bbc_keyboard_ps2 */
330 extern
331 module bbc_keyboard_ps2( clock clk "Clock of PS2 keyboard",
332  input bit reset_n,
333  input t_ps2_key_state ps2_key,
334  output t_bbc_keyboard keyboard
335  )
336 {
337  timing to rising clock clk ps2_key;
338  timing from rising clock clk keyboard;
339 }
340 
341 /*m bbc_floppy_sram */
342 extern module bbc_floppy_sram( clock clk "Clock running at 2MHz",
343  input bit reset_n,
344  input t_bbc_floppy_op floppy_op,
345  output t_bbc_floppy_response floppy_response,
346  output t_bbc_floppy_sram_request sram_request,
347  input t_bbc_floppy_sram_response sram_response,
348  input t_csr_request csr_request,
349  output t_csr_response csr_response
350 )
351 {
352  timing to rising clock clk floppy_op, sram_response, csr_request;
353  timing from rising clock clk floppy_response, sram_request, csr_response;
354 }
355 
356 /*m bbc_display */
357 extern module bbc_display( clock clk "Clock running at 2MHz",
358  //input bit reset_n,
359  input t_bbc_display_sram_write display_sram_write,
360  input t_bbc_floppy_sram_request floppy_sram_request,
361  output t_bbc_keyboard keyboard,
362  output bit reset_n,
363  output t_bbc_floppy_sram_response floppy_sram_response )
364 {
365  timing to rising clock clk display_sram_write, floppy_sram_request;
366  timing from rising clock clk keyboard, floppy_sram_response;
367 }
368 
module fdc8271(clock clk, input bit reset_n, input bit chip_select_n, input bit read_n, input bit write_n, input bit[2] address, input bit[8] data_in, output bit[8] data_out, output bit irq_n, output bit data_req, input bit data_ack_n, output bit[2] select, input bit[2] ready, output bit fault_reset, output bit write_enable, output bit seek_step, output bit direction, output bit load_head, output bit low_current, input bit track_0_n, input bit write_protect_n, input bit index_n, output t_bbc_floppy_op bbc_floppy_op, input t_bbc_floppy_response bbc_floppy_response)
Definition: bbc_submodules.h:212
Definition: bbc_micro_types.h:254
module bbc_micro_keyboard(clock clk, input bit reset_n, output bit reset_out_n, input bit keyboard_enable_n, input bit[4] column_select, input bit[3] row_select, output bit key_in_column_pressed, output bit selected_key_pressed, input t_bbc_keyboard bbc_keyboard)
Definition: bbc_submodules.h:116
Definition: bbc_micro_types.h:269
module bbc_vidproc(clock clk_cpu, clock clk_2MHz_video, input bit reset_n, input bit chip_select_n, input bit address, input bit[8] cpu_data_in, input bit[8] pixel_data_in, input bit disen, input bit invert_n, input bit cursor, input bit[6] saa5050_red, input bit[6] saa5050_green, input bit[6] saa5050_blue, output bit crtc_clock_enable, output bit[8] red, output bit[8] green, output bit[8] blue, output t_bbc_pixels_per_clock pixels_valid_per_clock)
Definition: bbc_submodules.h:34
module bbc_floppy_sram(clock clk, input bit reset_n, input t_bbc_floppy_op floppy_op, output t_bbc_floppy_response floppy_response, output t_bbc_floppy_sram_request sram_request, input t_bbc_floppy_sram_response sram_response, input t_csr_request csr_request, output t_csr_response csr_response)
Definition: bbc_submodules.h:342
module cpu6502(clock clk, input bit reset_n, input bit ready, input bit irq_n, input bit nmi_n, output bit ba, output bit[16] address, output bit read_not_write, output bit[8] data_out, input bit[8] data_in)
Definition: bbc_submodules.h:168
Definition: csr_interface.h:61
Definition: bbc_micro_types.h:334
Definition: bbc_micro_types.h:319
module bbc_display(clock clk, input t_bbc_display_sram_write display_sram_write, input t_bbc_floppy_sram_request floppy_sram_request, output t_bbc_keyboard keyboard, output bit reset_n, output t_bbc_floppy_sram_response floppy_sram_response)
Definition: bbc_submodules.h:357
module bbc_display_sram(clock clk, input bit reset_n, input t_bbc_display display, output t_bbc_display_sram_write sram_write, input t_csr_request csr_request, output t_csr_response csr_response)
Definition: bbc_submodules.h:304
Definition: csr_interface.h:82
module bbc_micro_clocking(clock clk, input bit reset_n, input t_bbc_clock_status clock_status, output t_bbc_clock_control clock_control, input t_csr_request csr_request, output t_csr_response csr_response)
Definition: bbc_submodules.h:253
Definition: input_devices.h:152
module bbc_keyboard_csr(clock clk, input bit reset_n, output t_bbc_keyboard keyboard, input bit keyboard_reset_n, input t_csr_request csr_request, output t_csr_response csr_response)
Definition: bbc_submodules.h:317
Definition: bbc_micro_types.h:84
module via6522(clock clk, clock clk_io, input bit reset_n, input bit read_not_write, input bit chip_select, input bit chip_select_n, input bit[4] address, input bit[8] data_in, output bit[8] data_out, output bit irq_n, input bit ca1, input bit ca2_in, output bit ca2_out, output bit[8] pa_out, input bit[8] pa_in, input bit cb1, input bit cb2_in, output bit cb2_out, output bit[8] pb_out, input bit[8] pb_in)
Definition: bbc_submodules.h:135
module saa5050(clock clk_2MHz, input bit clk_1MHz_enable, input bit reset_n, input bit superimpose_n, input bit data_n, input bit[7] data_in, input bit dlim, input bit glr, input bit dew, input bit crs, input bit bcs_n, output bit tlc_n, input bit lose, input bit de, input bit po, output bit[6] red, output bit[6] green, output bit[6] blue, output bit blan, input t_bbc_micro_sram_request host_sram_request)
Definition: bbc_submodules.h:185
Definition: bbc_micro_types.h:109
Definition: bbc_micro_types.h:287
module crtc6845(clock clk_2MHz, clock clk_1MHz, input bit reset_n, output bit[14] ma, output bit[5] ra, input bit read_not_write, input bit chip_select_n, input bit rs, input bit[8] data_in, output bit[8] data_out, input bit lpstb_n, input bit crtc_clock_enable, output bit de, output bit cursor, output bit hsync, output bit vsync)
Definition: bbc_submodules.h:63
Definition: bbc_micro_types.h:179
module bbc_micro_rams(clock clk, input bit reset_n, input t_bbc_clock_control clock_control, input t_bbc_micro_sram_request host_sram_request, output t_bbc_micro_sram_response host_sram_response, input t_bbc_display_sram_write display_sram_write, input t_bbc_floppy_sram_request floppy_sram_request, output t_bbc_floppy_sram_response floppy_sram_response, output t_bbc_micro_sram_request bbc_micro_host_sram_request, input t_bbc_micro_sram_response bbc_micro_host_sram_response)
Definition: bbc_submodules.h:267
module bbc_micro(clock clk, input t_bbc_clock_control clock_control, output t_bbc_clock_status clock_status, input bit reset_n, input t_bbc_keyboard keyboard, output t_bbc_display display, output bit keyboard_reset_n, output t_bbc_floppy_op floppy_op, input t_bbc_floppy_response floppy_response, input t_bbc_micro_sram_request host_sram_request, output t_bbc_micro_sram_response host_sram_response)
Definition: bbc_submodules.h:284
t_bbc_pixels_per_clock
Definition: bbc_micro_types.h:65
module bbc_keyboard_ps2(clock clk, input bit reset_n, input t_ps2_key_state ps2_key, output t_bbc_keyboard keyboard)
Definition: bbc_submodules.h:331
Definition: bbc_micro_types.h:41
Definition: bbc_micro_types.h:241
Definition: bbc_micro_types.h:224
module acia6850(clock clk, input bit reset_n, input bit read_not_write, input bit[2] chip_select, input bit chip_select_n, input bit address, input bit[8] data_in, output bit[8] data_out, output bit irq_n, input bit tx_clk, input bit rx_clk, output bit txd, input bit cts, input bit rxd, output bit rts, input bit dcd)
Definition: bbc_submodules.h:89