這不是關於實際創建帶inout端口的verilog模塊。有很多我發現的帖子。如何寫入inout端口並從同一模塊的inout端口讀取?
我所堅持的就是,如果我有一個INOUT端口一個黑箱模塊,讓我們說這就像
module blackbox(inout a, in b, in c)
定義,我想它實例在不同的模塊,像
module myModule(input reg inReg, output wire outWire) blackbox(outWire);
我該如何使用inReg驅動黑匣子並在不同的時間在outWire上輸出它?我不知道連接一個和斷開另一個的方法。這顯然過於簡單了。我真的有以下,但它更復雜。
module sram_control(
input wire HCLK,
input wire [20:0] HADDR,
input wire HWRITE,
input wire [1:0] HTRANS,
input wire [7:0] HWDATA,
output reg [7:0] HRDATA
);
parameter IDLE_PHASE = 2'b00;
parameter WRITE_PHASE = 2'b01;
parameter READ_PHASE = 2'b10;
parameter IDLE = 2'b00;
parameter NONSEQ = 2'b10;
parameter READ = 1'b0;
parameter WRITE = 1'b1;
reg current_state, next_state;
wire CE, WE, OE;
reg [20:0] A;
wire [7:0] DQ;
reg [7:0] DQ_tmp1;
wire [7:0] DQ_tmp2;
async the_mem(.CE_b(CE), .WE_b(WE), .OE_b(OE), .A(A), .DQ(DQ));
always @(posedge HCLK) begin
if(current_state == IDLE_PHASE) begin
next_state <= HTRANS == NONSEQ? (HWRITE == WRITE? WRITE_PHASE : READ_PHASE) : IDLE_PHASE;
A <= HADDR;
end
else if(current_state != IDLE_PHASE) begin
if(HTRANS == NONSEQ) begin
if(HWRITE == WRITE) begin
next_state <= WRITE_PHASE;
end
else begin
next_state <= READ_PHASE;
end
end
else next_state <= IDLE_PHASE;
end
// we never get here
else next_state <= IDLE_PHASE;
end
[email protected](posedge HCLK) begin
if(current_state == READ_PHASE) HRDATA <= DQ;
end
assign CE = current_state != IDLE_PHASE? 1 : 0;
assign WE = current_state != IDLE && HWRITE == WRITE? 1 : 0;
assign OE = current_state != IDLE_PHASE? 1 : 0;
[email protected](posedge HCLK) current_state <= next_state;
endmodule
我需要的是HWDATA分配給異步模塊時,我想寫信給它一個方式,我需要一種方法來分配異步模塊HRDATA的輸出時,我想從讀異步。
事實證明,我已經做到了這一點,並認爲這是我的問題,當它不是。不過,感謝一羣人向我展示了我實際上正在看錯我認爲是我的問題的地方。 – FatherOfNations