2024-10-21 20:01:45 -04:00

43 lines
1.1 KiB
Verilog

/**
* SRAM controller:
* If load[t] == 1 then out[t+1] = in[t]
* OEX[t+1] = 1
* WEX[t+1] = 0
* DATA[t+1] = in[t] (DATA is configured as output)
* At any other time:
* out = DATA (DATA is configured as input)
* CSX =0;
*/
`default_nettype none
module SRAM_D(
input clk,
input load,
input [15:0] in,
output [15:0] out,
inout [15:0] DATA, // SRAM data 16 Bit
output CSX, // SRAM chip_enable_not
output reg OEX, // SRAM output_enable_not
output reg WEX // SRAM write_enable_not
);
// Put your code here:
reg [15:0] to_sram;
always @(posedge clk) begin
if (load) begin
OEX <= 1;
WEX <= 0;
to_sram <= in;
end else begin
OEX <= 0;
WEX <= 1;
end
end
//DFF DFF(clk, load, LOAD);
//Register Register(clk, in, load, to_sram);
// assign OEX = (LOAD) ? 1 : 0;
// assign WEX = (LOAD) ? 0 : 1;
assign CSX = 0;
InOut InOut(DATA, to_sram, out, OEX);
endmodule