65 lines
1.3 KiB
Plaintext
65 lines
1.3 KiB
Plaintext
/**
|
|
|
|
A Connection between two Nodes, blocks
|
|
|
|
|
|
*/
|
|
|
|
global G_nodeCon {
|
|
const WIDTH = 11;
|
|
|
|
struct nodeConIn {
|
|
write,
|
|
read,
|
|
enable,
|
|
signed in[WIDTH]
|
|
}
|
|
}
|
|
|
|
module nodeCon (
|
|
|
|
input clk, // clock
|
|
input rst, // reset
|
|
|
|
input<G_nodeCon.nodeConIn> a_in,
|
|
signed output a_out[GNode.WORDLEN],
|
|
|
|
output done, //erledigt (blokirung kann uafgehoben werden)
|
|
|
|
/*input b_write,
|
|
input b_read,
|
|
input b_enable,
|
|
input b_in[WIDTH],*/
|
|
input<G_nodeCon.nodeConIn> b_in,
|
|
signed output b_out[G_nodeCon.WIDTH],
|
|
|
|
output error //output 1 on deadlock
|
|
) {
|
|
|
|
dff internalBuff[G_nodeCon.WIDTH](#INIT(0), .clk(clk), .rst(rst));
|
|
|
|
always {
|
|
error = ((a_in.write && b_in.write) || (a_in.read && b_in.read)) && ~rst && a_in.enable && b_in.enable; // gleichzeitiges lesen oder schreiben und nicht reset
|
|
|
|
done = (a_in.write && b_in.write) || (a_in.read && b_in.write) && a_in.enable && b_in.enable;
|
|
|
|
a_out = 0;
|
|
if(a_in.enable) {
|
|
if(a_in.write) {
|
|
internalBuff.d = a_in;
|
|
} else if(a_in.read) {
|
|
a_out = internalBuff.q;
|
|
}
|
|
}
|
|
|
|
b_out = 0;
|
|
if(b_in.enable) {
|
|
if(b_in.write) {
|
|
internalBuff.d = b_in;
|
|
} else if(b_in.read) {
|
|
b_out = internalBuff.q;
|
|
}
|
|
}
|
|
}
|
|
}
|