// Example code for a PicoRV32 AHBLite System-on-Chip // Iain McNally // ECS, University of Soutampton // // // This version supports 3 AHBLite slaves: // // ahb_ram RAM // ahb_switches A handshaking interface to support input from switches and buttons // ahb_out An output interface supporting simultaneous update of data and valid signals // module soc( input HCLK, HRESETn, input [15:0] Switches, input [1:0] Buttons, output [15:0] DataOut, output DataValid, output LOCKUP ); timeunit 1ns; timeprecision 100ps; // Global & Master AHB Signals wire [31:0] HADDR, HWDATA, HRDATA; wire [1:0] HTRANS; wire [2:0] HSIZE, HBURST; wire [3:0] HPROT; wire HWRITE, HMASTLOCK, HRESP, HREADY; // Per-Slave AHB Signals wire HSEL_RAM, HSEL_SW, HSEL_DOUT; wire [31:0] HRDATA_RAM, HRDATA_SW, HRDATA_DOUT; wire HREADYOUT_RAM, HREADYOUT_SW, HREADYOUT_DOUT; // Set this to zero because PicoRV32 does not support LOCKUP assign LOCKUP = '0; // Set this to zero because simple slaves do not generate errors assign HRESP = '0; // PicoRV32 is AHB Master picorv32_ahb riscv_1 ( // AHB Signals .HCLK, .HRESETn, .HADDR, .HBURST, .HMASTLOCK, .HPROT, .HSIZE, .HTRANS, .HWDATA, .HWRITE, .HRDATA, .HREADY, .HRESP ); // AHB interconnect including address decoder, register and multiplexer ahb_interconnect interconnect_1 ( .HCLK, .HRESETn, .HADDR, .HRDATA, .HREADY, .HSEL_SIGNALS({HSEL_DOUT,HSEL_SW,HSEL_RAM}), .HRDATA_SIGNALS({HRDATA_DOUT,HRDATA_SW,HRDATA_RAM}), .HREADYOUT_SIGNALS({HREADYOUT_DOUT,HREADYOUT_SW,HREADYOUT_RAM}) ); // AHBLite Slaves ahb_ram ram_1 ( .HCLK, .HRESETn, .HADDR, .HWDATA, .HSIZE, .HTRANS, .HWRITE, .HREADY, .HSEL(HSEL_RAM), .HRDATA(HRDATA_RAM), .HREADYOUT(HREADYOUT_RAM) ); ahb_switches switches_1 ( .HCLK, .HRESETn, .HADDR, .HWDATA, .HSIZE, .HTRANS, .HWRITE, .HREADY, .HSEL(HSEL_SW), .HRDATA(HRDATA_SW), .HREADYOUT(HREADYOUT_SW), .Switches(Switches), .Buttons(Buttons) ); ahb_out out_1 ( .HCLK, .HRESETn, .HADDR, .HWDATA, .HSIZE, .HTRANS, .HWRITE, .HREADY, .HSEL(HSEL_DOUT), .HRDATA(HRDATA_DOUT), .HREADYOUT(HREADYOUT_DOUT), .DataOut(DataOut), .DataValid(DataValid) ); //------------------------- // Assertions which should be valid for all systems: // // Control signals from master should never be undefined HTRANS_defined: assert property(@(posedge HCLK) disable iff (!HRESETn) ( ! $isunknown(HTRANS) ) ) else $error("HTRANS is undefined: %b", HTRANS); HWRITE_defined: assert property(@(posedge HCLK) disable iff (!HRESETn) ( ! $isunknown(HWRITE) ) ) else $error("HWRITE is undefined"); HSIZE_defined: assert property(@(posedge HCLK) disable iff (!HRESETn) ( ! $isunknown(HSIZE) ) ) else $error("HSIZE is undefined: %b", HSIZE); HADDR_defined: assert property(@(posedge HCLK) disable iff (!HRESETn) ( ! $isunknown(HADDR) ) ) else $error("HADDR is undefined: %b", HADDR); // Data signal from master should be defined during write HWDATA_defined: assert property(@(posedge HCLK) disable iff (!HRESETn) (HWRITE && HREADY) |=> ( ! $isunknown(HWDATA) ) ) else $error("HWDATA is undefined during write data phase: %b", HWDATA); endmodule