/////////////////////////////////////////////////////////////////////// // // system module // // this is the top-level module which describes the complete system // /////////////////////////////////////////////////////////////////////// `include "opcodes.sv" module system; timeunit 1ns; timeprecision 100ps; import definitions::*; logic Clock, nReset, Test, SDI; logic nMEi, ALEi, RnWi, nOEi; logic [15:0] switches; wire [15:0] LEDs; wire [15:0] Data; wire [15:0] Address; wire ALE, nME, nOE, RnW, nIRQ, nWait; cpu CPU ( .Data(Data), .nME(nME), .ALE(ALE), .RnW(RnW), .nOE(nOE), .SDO(SDO), .nIRQ(nIRQ), .nWait(nWait), .Clock(Clock), .nReset(nReset), .Test(Test), .SDI(SDI) ); // define the interconnect fabric based on a SystemVerilog interface pullup (weak1) (nIRQ); pullup (weak1) (nWait); demux_bus Bus ( nIRQ, nWait, Data, Address, ALEi, nMEi, nOEi, RnWi ); bus_watch Bus_Watch ( Bus.Observer ); addlatch AddLatch ( Bus.AddressLatch ); decoder Decoder ( Bus.AddressDecode, nSelRAM, nSelLED, nSelSwitch, nSelTimer, nSelSerial ); // all the following are slaves attached to the bus ram RAM ( Bus.Slave, nSelRAM ); io_leds IO_LEDS ( Bus.Slave, LEDs, nSelLED ); io_switches IO_SWITCHES ( Bus.Slave, switches, nSelSwitch); io_timer IO_TIMER ( Bus.InterruptSlave, nSelTimer, Clock, nReset ); io_serial IO_SERIAL ( Bus.InterruptSlave, nSelSerial, Clock, nReset ); `ifdef hold_signals_during_reset always @(Test or nReset) if (! nReset) begin nMEi = 1; ALEi = 0; RnWi = 1; nOEi = 1; end else if (Test == 0) begin assign nMEi = nME; assign ALEi = ALE; assign RnWi = RnW; assign nOEi = nOE; end else begin deassign nMEi; assign ALEi = 0; // keep address bus constant deassign RnWi; assign nOEi = 1;// mem should not drive data bus end `else always @(Test) if (Test == 0) begin assign nMEi = nME; assign ALEi = ALE; assign RnWi = RnW; assign nOEi = nOE; end else begin deassign nMEi; assign ALEi = 0; // keep address bus constant deassign RnWi; assign nOEi = 1;// mem should not drive data bus end `endif `ifdef special_stimulus `include "stimulus.sv" `else initial begin Clock = 0; nReset = 0; #250ns nReset = 1; #500ns while ( 1 ) begin Clock = 0; #250ns Clock = 1; #500ns Clock = 0; #250ns Clock = 0; end end initial begin `ifdef switch_value switches = `switch_value; `else switches = 1; `endif Test = 0; SDI = 0; end `endif `ifdef special_monitor `include "monitor.sv" `endif `ifdef sim_time initial begin #`sim_time $stop; $finish; end `endif endmodule