-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtristate.sv.bak
executable file
·40 lines (33 loc) · 1.16 KB
/
tristate.sv.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//------------------------------------------------------------------------------
// Company: UIUC ECE Dept.
// Engineer: Stephen Kempf
//
// Create Date:
// Design Name: ECE 385 Lab 6 Given Code - Tristate buffer for SRAM
// Module Name: tristate
//
// Comments:
// Revised 02-13-2017
// Spring 2017 Distribution
//
//------------------------------------------------------------------------------
module tristate #(N = 16) (
input logic Clk,
input logic tristate_output_enable,
input logic [N-1:0] Data_write, // Data from Mem2IO
output logic [N-1:0] Data_read, // Data to Mem2IO
inout wire [N-1:0] Data // inout bus to SRAM
);
// Registers are needed between synchronized circuit and asynchronized SRAM
logic [N-1:0] Data_write_buffer, Data_read_buffer;
always_ff @(posedge Clk)
begin
// Always read data from the bus
Data_read_buffer <= Data;
// Always updated with the data from Mem2IO which will be written to the bus
Data_write_buffer <= Data_write;
end
// Drive (write to) Data bus only when tristate_output_enable is active.
assign Data = tristate_output_enable ? Data_write_buffer : {N{1'bZ}};
assign Data_read = Data_read_buffer;
endmodule