| 1 |
6 |
gdevic |
//============================================================================
|
| 2 |
|
|
// A-Z80 core, instantiates and connects all internal blocks.
|
| 3 |
|
|
//
|
| 4 |
|
|
// This file is included by the "z80_top_ifc_n" and "z80_top_direct" providing
|
| 5 |
|
|
// interface binding and direct (no interface) binding.
|
| 6 |
|
|
//============================================================================
|
| 7 |
|
|
|
| 8 |
|
|
// Include a list of top-level signal wires
|
| 9 |
|
|
`include "globals.vh"
|
| 10 |
|
|
|
| 11 |
8 |
gdevic |
// Specific to simulation, some modules in the schematics need to be pre-initialized
|
| 12 |
6 |
gdevic |
// to avoid starting simulations with unknown values in selected flip flops.
|
| 13 |
8 |
gdevic |
reg fpga_reset = 1;
|
| 14 |
|
|
always @(posedge clk)
|
| 15 |
|
|
begin
|
| 16 |
|
|
fpga_reset <= 0;
|
| 17 |
6 |
gdevic |
end
|
| 18 |
|
|
|
| 19 |
8 |
gdevic |
// Define internal data bus partitions segmented by data bus switches
|
| 20 |
6 |
gdevic |
wire [7:0] db0; // Segment connecting data pins and IR
|
| 21 |
8 |
gdevic |
wire [7:0] db1; // Segment leading to the ALU
|
| 22 |
6 |
gdevic |
wire [7:0] db2; // Segment with msb part of the register address-side interface
|
| 23 |
|
|
|
| 24 |
8 |
gdevic |
wire [7:0] db_hi_as; // Register file data bus segment high byte
|
| 25 |
|
|
wire [7:0] db_lo_as; // Register file data bus segment low byte
|
| 26 |
|
|
|
| 27 |
|
|
wire [6:0] prefix; // Instruction decode PLA prefix bitfield
|
| 28 |
6 |
gdevic |
assign prefix = { ~use_ixiy, use_ixiy, ~in_halt, in_alu, table_xx, table_cb, table_ed };
|
| 29 |
|
|
|
| 30 |
8 |
gdevic |
wire nM1_int; // External pins timing control
|
| 31 |
|
|
assign nM1_int = !(setM1 | (fFetch & T1));
|
| 32 |
|
|
|
| 33 |
|
|
`include "coremodules.vh"
|
| 34 |
|
|
|
| 35 |
|
|
// Data path within the CPU in various forms, ending with data pins
|
| 36 |
|
|
data_switch sw2_( .sw_up_en(bus_sw_2u), .sw_down_en(bus_sw_2d), .db_up(db1[7:0]), .db_down(db2[7:0]) );
|
| 37 |
|
|
|
| 38 |
|
|
// Data switch SW1 with the data mask
|
| 39 |
|
|
data_switch_mask sw1_( .sw_mask543_en(bus_sw_mask543_en), .sw_up_en(bus_sw_1u), .sw_down_en(bus_sw_1d), .db_up(db0[7:0]), .db_down(db1[7:0]) );
|
| 40 |
|
|
|
| 41 |
|
|
/* This SystemVerilog-style code is kept for future reference
|
| 42 |
|
|
// Control block
|
| 43 |
|
|
clk_delay clk_delay_( .* );
|
| 44 |
|
|
decode_state decode_state_( .* );
|
| 45 |
6 |
gdevic |
execute execute_( .* );
|
| 46 |
|
|
interrupts interrupts_( .*, .db(db0[4:3]) );
|
| 47 |
8 |
gdevic |
ir ir_( .*, .db(db0[7:0]) );
|
| 48 |
6 |
gdevic |
pin_control pin_control_( .* );
|
| 49 |
8 |
gdevic |
pla_decode pla_decode_( .* );
|
| 50 |
|
|
resets resets_( .* );
|
| 51 |
|
|
sequencer sequencer_( .* );
|
| 52 |
6 |
gdevic |
|
| 53 |
|
|
// ALU and ALU control, including the flags
|
| 54 |
|
|
alu_control alu_control_( .*, .db(db1[7:0]), .op543({pla[104],pla[103],pla[102]}) );
|
| 55 |
|
|
alu_select alu_select_( .* );
|
| 56 |
|
|
alu_flags alu_flags_( .*, .db(db1[7:0]) );
|
| 57 |
|
|
alu alu_( .*, .db(db2[7:0]), .bsel(db0[5:3]) );
|
| 58 |
|
|
|
| 59 |
|
|
// Register file and register control
|
| 60 |
|
|
reg_file reg_file_( .*, .db_hi_ds(db2[7:0]), .db_lo_ds(db1[7:0]), .db_hi_as(db_hi_as[7:0]), .db_lo_as(db_lo_as[7:0]) );
|
| 61 |
|
|
reg_control reg_control_( .* );
|
| 62 |
|
|
|
| 63 |
8 |
gdevic |
// Address latch and the incrementer
|
| 64 |
6 |
gdevic |
address_latch address_latch_( .*, .abus({db_hi_as[7:0], db_lo_as[7:0]}) );
|
| 65 |
|
|
|
| 66 |
8 |
gdevic |
// Misc bus
|
| 67 |
|
|
bus_control bus_control_( .*, .db(db0[7:0]) );
|
| 68 |
|
|
bus_switch bus_switch_( .* );
|
| 69 |
|
|
|
| 70 |
6 |
gdevic |
// Timing control of the external pins
|
| 71 |
|
|
memory_ifc memory_ifc_( .* );
|
| 72 |
8 |
gdevic |
*/
|