Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
White Rabbit core collection
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
White Rabbit core collection
Commits
0262bd77
There was an error fetching the commit references. Please try again later.
Commit
0262bd77
authored
13 years ago
by
Tomasz Wlostowski
Browse files
Options
Downloads
Patches
Plain Diff
simulation models: added WBP packet source class
parent
bba7e499
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sim/wb_packet_source.svh
+144
-0
144 additions, 0 deletions
sim/wb_packet_source.svh
with
144 additions
and
0 deletions
sim/wb_packet_source.svh
0 → 100644
+
144
−
0
View file @
0262bd77
`ifndef
__
WB_PACKET_SOURCE_SVH
`define
__WB_PACKET_SOURCE_SVH
`include
"simdrv_defs.svh"
`include
"if_wishbone_accessor.svh"
virtual
class
EthPacketSource
;
static
int
_
null
=
0
;
pure
virtual
task
send
(
ref
EthPacket
pkt
,
ref
int
result
=
_
null
);
endclass
// PacketSource
class
WBPacketSource
extends
EthPacketSource
;
protected
CWishboneAccessor
m_acc
;
const
bit
[
2
:
0
]
WRF_STATUS
=
3'b110
;
const
bit
[
2
:
0
]
WRF_DATA
=
3'b000
;
const
bit
[
2
:
0
]
WRF_OOB
=
3'b010
;
const
bit
[
2
:
0
]
WRF_USER
=
3'b100
;
const
bit
[
3
:
0
]
WRF_OOB_TX_FID
=
4'b0000
;
const
bit
[
3
:
0
]
WRF_OOB_RX_TIMESTAMP
=
4'b0001
;
function
new
(
CWishboneAccessor
acc
);
m_acc
=
acc
;
endfunction
// new
function
bit
[
15
:
0
]
pack_status
(
ref
EthPacket
pkt
,
input
bit
error
=
0
);
bit
[
15
:
0
]
st
;
st
[
0
]
=
(
pkt
.
is_hp
?
1'b1
:
1'b0
);
st
[
1
]
=
1'b0
;
st
[
2
]
=
(
pkt
.
has_smac
?
1'b1
:
1'b0
);
st
[
3
]
=
error
;
st
[
15
:
3
]
=
0
;
// FIXME: add packet classes
return
st
;
endfunction
// pack_status
task
unpack_status
(
bit
[
15
:
0
]
status
,
ref
EthPacket
pkt
);
endtask
// unpack_status
typedef
bit
[
15
:
0
]
oob_array16
[];
function
u64_array_t
pack_oob
(
ref
EthPacket
pkt
);
u64_array_t
oob
;
case
(
pkt
.
oob_type
)
TX_FID:
begin
oob
=
new
[
2
];
oob
[
0
]
=
{
WRF_OOB_TX_FID
,
12'b0
}
;
oob
[
1
]
=
pkt
.
ts
.
frame_id
;
end
endcase
// case (pkt.oob_type)
return
oob
;
endfunction
// pack_oob
task
send
(
ref
EthPacket
pkt
,
ref
int
result
=
_
null
);
byte
pdata
[];
// FIXME: dynamic allocation would be better...
u64_array_t
pdata_p
;
u64_array_t
oob_p
;
int
i
,
len
;
wb_cycle_t
cyc
;
wb_xfer_t
xf
;
cyc
.
ctype
=
PIPELINED
;
/* First, the status register */
xf
.
a
=
WRF_STATUS
;
xf
.
d
=
pack_status
(
pkt
);
xf
.
size
=
2
;
cyc
.
data
.
push_back
(
xf
);
pkt
.
serialize
(
pdata
);
pdata_p
=
SimUtils
.
pack
(
pdata
,
2
,
1
);
len
=
pdata_p
.
size
();
for
(
i
=
0
;
i
<
len
;
i
++
)
begin
xf
.
a
=
WRF_DATA
;
if
(
i
==
len
-
1
&&
(
pdata
.
size
()
&
1
))
begin
xf
.
size
=
1
;
xf
.
d
=
pdata_p
[
i
]
>>
8
;
end
else
begin
xf
.
size
=
2
;
xf
.
d
=
pdata_p
[
i
];
end
cyc
.
data
.
push_back
(
xf
);
end
if
(
pkt
.
error
)
begin
xf
.
a
=
WRF_STATUS
;
xf
.
d
=
pack_status
(
pkt
,
1
);
xf
.
size
=
2
;
cyc
.
data
.
push_back
(
xf
);
end
else
begin
// $display("DataSize: %d\n", cyc.data.size());
oob_p
=
pack_oob
(
pkt
);
for
(
i
=
0
;
i
<
oob_p
.
size
();
i
++
)
begin
xf
.
a
=
WRF_OOB
;
xf
.
d
=
oob_p
[
i
]
&
'hffff
;
xf
.
size
=
2
;
cyc
.
data
.
push_back
(
xf
);
end
end
// else: !if(pkt.error)
m_acc
.
put
(
cyc
);
endtask
// send
endclass
// WBPacketSource
`endif
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment