Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
51c11c7e
Commit
51c11c7e
authored
Apr 10, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simulation module for LWIR sensor
parent
eb7ba9a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
16 deletions
+39
-16
simul_lwir160x120_vospi.v
simulation_modules/simul_lwir160x120_vospi.v
+39
-16
No files found.
simulation_modules/simul_lwir160x120_vospi.v
View file @
51c11c7e
...
@@ -42,16 +42,31 @@ module simul_lwir160x120_vospi # (
...
@@ -42,16 +42,31 @@ module simul_lwir160x120_vospi # (
parameter
DATA_FILE
=
"/data_ssd/nc393/elphel393/fpga-elphel/x393/input_data/pattern_160_120_14.dat"
,
//
parameter
DATA_FILE
=
"/data_ssd/nc393/elphel393/fpga-elphel/x393/input_data/pattern_160_120_14.dat"
,
//
parameter
WINDOW_WIDTH
=
160
,
//
parameter
WINDOW_WIDTH
=
160
,
//
parameter
WINDOW_HEIGHT
=
120
,
//
parameter
WINDOW_HEIGHT
=
120
,
//
parameter
LWIR_GPIO_IN
=
4'b0000
,
parameter
TELEMETRY
=
1
,
// 0 - disabled, 1 - as header, 2 - as footer
parameter
TELEMETRY
=
1
,
// 0 - disabled, 1 - as header, 2 - as footer
parameter
FRAME_PERIOD
=
946969
,
// 26.4 fps @25 MHz
parameter
FRAME_PERIOD
=
946969
,
// 26.4 fps @25 MHz
parameter
FRAME_DELAY
=
100
,
// mclk period to start first frame 1
parameter
FRAME_DELAY
=
100
,
// mclk period to start first frame 1
parameter
MS_PERIOD
=
25
// ahould actually be 25000
parameter
MS_PERIOD
=
25
// ahould actually be 25000
)(
)(
input
mclk
,
input
mclk
,
input
nrst
,
input
mrst
,
// active low
input
sck
,
input
pwdn
,
// active low
input
ncs
,
input
spi_clk
,
output
miso
,
input
spi_cs
,
output
spi_miso
,
input
spi_mosi
,
inout
gpio0
,
inout
gpio1
,
inout
gpio2
,
inout
gpio3
,
// may be used as segment sync (ready)
input
i2c_scl
,
inout
i2c_sda
,
output
mipi_dp
,
// not implemented
output
mipi_dn
,
// not implemented
output
mipi_clkp
,
// not implemented
output
mipi_clkn
,
// not implemented
// telemetry data
// telemetry data
input
[
15
:
0
]
telemetry_rev
,
input
[
15
:
0
]
telemetry_rev
,
input
[
31
:
0
]
telemetry_status
,
input
[
31
:
0
]
telemetry_status
,
...
@@ -80,7 +95,7 @@ module simul_lwir160x120_vospi # (
...
@@ -80,7 +95,7 @@ module simul_lwir160x120_vospi # (
localparam
FRAMES
=
2
;
// 2 frames in a ping-pong buffer
localparam
FRAMES
=
2
;
// 2 frames in a ping-pong buffer
localparam
FRAME_WORDS
=
FRAME_SEGMENTS
*
(
SEGMENT_PACKETS
+
((
TELEMETRY
>
0
)
?
1
:
0
))
*
PACKET_WORDS
;
localparam
FRAME_WORDS
=
FRAME_SEGMENTS
*
(
SEGMENT_PACKETS
+
((
TELEMETRY
>
0
)
?
1
:
0
))
*
PACKET_WORDS
;
wire
mrst
=
!
n
rst
;
wire
rst
=
!
m
rst
;
reg
[
OUT_BITS
-
1
:
0
]
sensor_data
[
0
:
WINDOW_WIDTH
*
WINDOW_HEIGHT
-
1
]
;
// SuppressThisWarning VEditor - Will be assigned by $readmem
reg
[
OUT_BITS
-
1
:
0
]
sensor_data
[
0
:
WINDOW_WIDTH
*
WINDOW_HEIGHT
-
1
]
;
// SuppressThisWarning VEditor - Will be assigned by $readmem
reg
[
OUT_BITS
-
1
:
0
]
packed_data
[
0
:
FRAMES
*
FRAME_WORDS
-
1
]
;
reg
[
OUT_BITS
-
1
:
0
]
packed_data
[
0
:
FRAMES
*
FRAME_WORDS
-
1
]
;
...
@@ -133,8 +148,18 @@ module simul_lwir160x120_vospi # (
...
@@ -133,8 +148,18 @@ module simul_lwir160x120_vospi # (
// wire [ 2:0] copy_segment;
// wire [ 2:0] copy_segment;
//946,969 '0xe7319'
//946,969 '0xe7319'
assign
mipi_dp
=
'bz
;
// assign copy_done = copy_run && copy_crc &&((TELEMETRY==0) ? (copy_packet== (FRAME_PACKETS -1)) : (FRAME_PACKETS + 3));
assign
mipi_dn
=
'bz
;
assign
mipi_clkp
=
'bz
;
assign
mipi_clkn
=
'bz
;
assign
gpio0
=
LWIR_GPIO_IN
[
0
]
?
'bz
:
0
;
assign
gpio1
=
LWIR_GPIO_IN
[
1
]
?
'bz
:
0
;
assign
gpio2
=
LWIR_GPIO_IN
[
2
]
?
'bz
:
0
;
assign
gpio3
=
LWIR_GPIO_IN
[
3
]
?
'bz
:
0
;
assign
i2c_sda
=
'bz
;
assign
copy_done
=
copy_run
&&
copy_crc
&&
(
copy_packet
==
(
FRAME_PACKETS_FULL
-
1
))
;
assign
copy_done
=
copy_run
&&
copy_crc
&&
(
copy_packet
==
(
FRAME_PACKETS_FULL
-
1
))
;
assign
copy_packet_full
=
(
copy_packet
<
FRAME_PACKETS
)
?
(
copy_packet
+
((
TELEMETRY
==
1
)
?
4
:
0
))
:
(
copy_packet
-
((
TELEMETRY
==
1
)
?
FRAME_PACKETS
:
0
))
;
assign
copy_packet_full
=
(
copy_packet
<
FRAME_PACKETS
)
?
(
copy_packet
+
((
TELEMETRY
==
1
)
?
4
:
0
))
:
(
copy_packet
-
((
TELEMETRY
==
1
)
?
FRAME_PACKETS
:
0
))
;
...
@@ -170,26 +195,26 @@ initial begin
...
@@ -170,26 +195,26 @@ initial begin
$
readmemh
(
DATA_FILE
,
sensor_data
,
0
)
;
$
readmemh
(
DATA_FILE
,
sensor_data
,
0
)
;
end
end
always
@
(
posedge
mclk
)
begin
always
@
(
posedge
mclk
)
begin
if
(
m
rst
||
(
ms_cntr
==
0
))
ms_cntr
<=
MS_PERIOD
-
1
;
if
(
rst
||
(
ms_cntr
==
0
))
ms_cntr
<=
MS_PERIOD
-
1
;
else
ms_cntr
<=
ms_cntr
-
1
;
else
ms_cntr
<=
ms_cntr
-
1
;
if
(
m
rst
)
time_ms
<=
0
;
if
(
rst
)
time_ms
<=
0
;
else
if
((
ms_cntr
==
0
))
time_ms
<=
time_ms
+
1
;
else
if
((
ms_cntr
==
0
))
time_ms
<=
time_ms
+
1
;
//restarting frames
//restarting frames
if
(
m
rst
)
frame_dly_cntr
<=
FRAME_DELAY
;
if
(
rst
)
frame_dly_cntr
<=
FRAME_DELAY
;
else
if
(
frame_start
)
frame_dly_cntr
<=
FRAME_PERIOD
;
else
if
(
frame_start
)
frame_dly_cntr
<=
FRAME_PERIOD
;
else
frame_dly_cntr
<=
frame_dly_cntr
-
1
;
else
frame_dly_cntr
<=
frame_dly_cntr
-
1
;
frame_start
<=
!
m
rst
&&
(
frame_dly_cntr
==
0
)
;
frame_start
<=
!
rst
&&
(
frame_dly_cntr
==
0
)
;
if
(
m
rst
)
frame_num
<=
0
;
if
(
rst
)
frame_num
<=
0
;
else
if
(
frame_start
)
frame_num
<=
frame_num
+
1
;
else
if
(
frame_start
)
frame_num
<=
frame_num
+
1
;
if
(
m
rst
)
copy_page
<=
0
;
if
(
rst
)
copy_page
<=
0
;
else
if
(
frame_start
)
copy_page
<=
!
copy_page
;
else
if
(
frame_start
)
copy_page
<=
!
copy_page
;
if
(
m
rst
||
copy_done
)
copy_run
<=
0
;
if
(
rst
||
copy_done
)
copy_run
<=
0
;
else
if
(
frame_start
)
copy_run
<=
1
;
else
if
(
frame_start
)
copy_run
<=
1
;
copy_crc
<=
copy_word
==
(
PACKET_WORDS
-
1
)
;
copy_crc
<=
copy_word
==
(
PACKET_WORDS
-
1
)
;
...
@@ -223,7 +248,6 @@ always @ (posedge mclk) begin
...
@@ -223,7 +248,6 @@ always @ (posedge mclk) begin
end
end
/* Instance template for module crc16_x16x12x5x0 */
crc16_x16x12x5x0
crc16_x16x12x5x0_i
(
crc16_x16x12x5x0
crc16_x16x12x5x0_i
(
.
clk
(
mclk
)
,
// input
.
clk
(
mclk
)
,
// input
.
srst
(
!
copy_run
||
copy_crc
)
,
// input
.
srst
(
!
copy_run
||
copy_crc
)
,
// input
...
@@ -234,7 +258,6 @@ end
...
@@ -234,7 +258,6 @@ end
)
;
)
;
/* Instance template for module simul_lwir160x120_telemetry */
simul_lwir160x120_telemetry
simul_lwir160x120_telemetry_i
(
simul_lwir160x120_telemetry
simul_lwir160x120_telemetry_i
(
.
clk
(
mclk
)
,
// input
.
clk
(
mclk
)
,
// input
.
en
(
frame_start
)
,
// input
.
en
(
frame_start
)
,
// input
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment