0gVFi:l3B4U1
+R9
+33
+R156
+!i10b 1
+R11
+R157
+R158
+!i113 1
+R14
+R15
+Pgeneric_sequencer_15_pkg
+R3
+R2
+R5
+R6
+w1608021839
+R0
+8../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd
+F../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd
+l0
+L26
+VmhUm4iEJAomYkT`;W1AP^3
+!s100 eH@M9aKo9^gd=M>U8jVh@3
+R9
+33
+R10
+!i10b 1
+R11
+!s90 -reportprogress|300|-2008|-work|work|../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd|
+!s107 ../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd|
+!i113 1
+R14
+R15
+Egeneric_sequencer_16
+R1
+Z159 DPx4 work 24 generic_sequencer_16_pkg 0 22 bCd4370W87XUj3X8iV=A=3
+R3
+R2
+R5
+R6
+R0
+Z160 8../../../generic_sequencer/16/src/generic_sequencer_16.vhd
+Z161 F../../../generic_sequencer/16/src/generic_sequencer_16.vhd
+l0
+L25
+Vg8AYaZ5T3hk?ChHP9AljS3
+!s100 S8EW9^NIAUkQOgA^T;d`i0
+R9
+33
+R156
+!i10b 1
+Z162 !s108 1610032424.000000
+Z163 !s90 -reportprogress|300|-2008|-work|work|../../../generic_sequencer/16/src/generic_sequencer_16.vhd|
+Z164 !s107 ../../../generic_sequencer/16/src/generic_sequencer_16.vhd|
+!i113 1
+R14
+R15
+Artl
+R4
+R16
+R159
+R3
+R2
+R5
+R6
+Z165 DEx4 work 20 generic_sequencer_16 0 22 g8AYaZ5T3hk?ChHP9AljS3
+l182
+L74
+VE7daXS;DFK4Xhn^Mj:71h2
+!s100 aWkPbnAk>Pg>J[M7;MJV;0
+R9
+33
+R156
+!i10b 1
+R162
+R163
+R164
+!i113 1
+R14
+R15
+Pgeneric_sequencer_16_pkg
+R3
+R2
+R5
+R6
+w1608021841
+R0
+8../../../generic_sequencer/16/src/generic_sequencer_16_pkg.vhd
+F../../../generic_sequencer/16/src/generic_sequencer_16_pkg.vhd
+l0
+L26
+VbCd4370W87XUj3X8iV=A=3
+!s100 3O:<`;IaN>=0Q=CahE6>20
+R9
+33
+R156
+!i10b 1
+R162
+!s90 -reportprogress|300|-2008|-work|work|../../../generic_sequencer/16/src/generic_sequencer_16_pkg.vhd|
+!s107 ../../../generic_sequencer/16/src/generic_sequencer_16_pkg.vhd|
+!i113 1
+R14
+R15
+Plog_pkg
+R42
+R22
+R2
+R5
+R6
+Z166 w1608021789
+R0
+Z167 8../../../common/0/src/test/log_pkg.vhd
+Z168 F../../../common/0/src/test/log_pkg.vhd
+l0
+L29
+VXk0SYUH]oa@]:2Q@;PP4WC3Offh]Z6820
+R9
+33
+R81
+!i10b 1
+R82
+Z173 !s90 -reportprogress|300|-2008|-work|work|../../../encoder_multiply/0/src/lut_divider_0.vhd|
+Z174 !s107 ../../../encoder_multiply/0/src/lut_divider_0.vhd|
+!i113 1
+R14
+R15
+Artl
+R3
+R2
+R5
+R6
+R98
+l80
+L38
+VO2MEBR8n>LT8Z;cCV1lW02
+!s100 ]5zGAKmjjc@@VP=MQXL;13
+R9
+33
+R81
+!i10b 1
+R82
+R173
+R174
+!i113 1
+R14
+R15
+Epof_rx_0
+Z175 w1608021845
+R2
+R5
+R6
+R0
+Z176 8../../../pof_protocol/0/src/pof_rx_0.vhd
+Z177 F../../../pof_protocol/0/src/pof_rx_0.vhd
+l0
+L22
+Vi4^5JjV5GkP7GU4`7Lj`A0
+!s100 2igd6:LzYQM=z8_WHG>K_0
+R9
+33
+Z178 !s110 1610032427
+!i10b 1
+Z179 !s108 1610032427.000000
+Z180 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/pof_rx_0.vhd|
+Z181 !s107 ../../../pof_protocol/0/src/pof_rx_0.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+Z182 DEx4 work 15 sync_wire_redge 0 22 i`Y_eUL[MQ07R1kFeezIK2
+Z183 DEx4 work 13 pof_uart_rx_0 0 22 4UN=F08B[C66nnRniO`d@1
+R2
+R5
+R6
+R130
+l94
+L49
+VDaSLLSYcoPCodTWg?a]@01
+!s100 N4VRfc6Z_Z]CaVemjQQG:3
+R9
+33
+R178
+!i10b 1
+R179
+R180
+R181
+!i113 1
+R14
+R15
+Epof_rx_1
+Z184 w1608021849
+R2
+R5
+R6
+R0
+Z185 8../../../pof_protocol/1/src/pof_rx_1.vhd
+Z186 F../../../pof_protocol/1/src/pof_rx_1.vhd
+l0
+L22
+VThDkJkG__b=:ZRBLB`mEQ2
+!s100 =NHCNz>S[fGM>MD90`D]90
+R9
+33
+Z187 !s110 1610032428
+!i10b 1
+Z188 !s108 1610032428.000000
+Z189 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/1/src/pof_rx_1.vhd|
+Z190 !s107 ../../../pof_protocol/1/src/pof_rx_1.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+R182
+Z191 DEx4 work 13 pof_uart_rx_1 0 22 IdB@T2OTYenXR:eYN[0i51
+R2
+R5
+R6
+R128
+l96
+L50
+V0U@Ze9TZHg0mRXlaZM1Nm2
+!s100 dCooXm9jTj;bz4gla1k^P2
+R9
+33
+R187
+!i10b 1
+R188
+R189
+R190
+!i113 1
+R14
+R15
+Epof_tx_0
+Z192 w1608202702
+R2
+R5
+R6
+R0
+Z193 8../../../pof_protocol/0/src/pof_tx_0.vhd
+Z194 F../../../pof_protocol/0/src/pof_tx_0.vhd
+l0
+L22
+V2ng4RmiL@4B?gnLf2gF]:1
+!s100 7Tg=HMOOB[D3G]R>4`Sn0DU1
+R3
+R105
+R2
+R5
+R6
+R126
+l90
+L41
+VWZn>EAoJ=>aC`9gaE>_Xe0
+!s100 ;f]A`A>ImLYP3_c4]K?670
+R9
+33
+R187
+!i10b 1
+R188
+R195
+R196
+!i113 1
+R14
+R15
+Epof_tx_0_csr_regs
+R72
+R197
+R2
+R5
+R6
+R0
+Z200 8../../../pof_protocol/0/src/pof_tx_0_csr_regs_auto.vhd
+Z201 F../../../pof_protocol/0/src/pof_tx_0_csr_regs_auto.vhd
+l0
+L29
+VKNOoG3Z[cP0_8nL1=[kB[2
+!s100 Sb[[cF_9ioc]n1eX]Cezd3
+R9
+33
+R178
+!i10b 1
+R179
+Z202 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/pof_tx_0_csr_regs_auto.vhd|
+Z203 !s107 ../../../pof_protocol/0/src/pof_tx_0_csr_regs_auto.vhd|
+!i113 1
+R14
+R15
+Artl
+R197
+R2
+R5
+R6
+R198
+l85
+L63
+V8o;VGQH8^2Il9F;:8FQU60
+!s100 :VNT2E96IL5I>K8X:kY5^3
+R9
+33
+R178
+!i10b 1
+R179
+R202
+R203
+!i113 1
+R14
+R15
+Ppof_tx_0_pkg
+R2
+R5
+R6
+R72
+R0
+8../../../pof_protocol/0/src/pof_tx_0_pkg_auto.vhd
+F../../../pof_protocol/0/src/pof_tx_0_pkg_auto.vhd
+l0
+L8
+V8BY135Y]UlSbl7hY48kzZ3
+!s100 [?Z2V[;C1HzdF07@?3dih0
+R9
+33
+R178
+!i10b 1
+R179
+!s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/pof_tx_0_pkg_auto.vhd|
+!s107 ../../../pof_protocol/0/src/pof_tx_0_pkg_auto.vhd|
+!i113 1
+R14
+R15
+Epof_tx_1
+R184
+R2
+R5
+R6
+R0
+Z204 8../../../pof_protocol/1/src/pof_tx_1.vhd
+Z205 F../../../pof_protocol/1/src/pof_tx_1.vhd
+l0
+L23
+VgCbI@Sf:63@L>HHol5T9AYC00
+!s100 ZJHXo9BzLEI[g`:PT6m1j3
+R9
+33
+R187
+!i10b 1
+R188
+R206
+R207
+!i113 1
+R14
+R15
+Epof_uart_regen_0
+R175
+R2
+R5
+R6
+R0
+Z209 8../../../pof_protocol/0/src/pof_uart_regen_0.vhd
+Z210 F../../../pof_protocol/0/src/pof_uart_regen_0.vhd
+l0
+L22
+VI^FA]UFMd[nf1e[ZhFm5E0
+!s100 DR];=ZoEdXW4eT9gaOVbQ2
+R9
+33
+R178
+!i10b 1
+R179
+Z211 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/pof_uart_regen_0.vhd|
+Z212 !s107 ../../../pof_protocol/0/src/pof_uart_regen_0.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+R2
+R5
+R6
+R129
+l44
+L36
+V@H>fe3dDdh3OC@megPRiJ0
+!s100 cMONYKl]hkD8;_eIodL9j1
+R9
+33
+R178
+!i10b 1
+R179
+R211
+R212
+!i113 1
+R14
+R15
+Epof_uart_regen_1
+R184
+R2
+R5
+R6
+R0
+Z213 8../../../pof_protocol/1/src/pof_uart_regen_1.vhd
+Z214 F../../../pof_protocol/1/src/pof_uart_regen_1.vhd
+l0
+L22
+V3F^4CLUf_1jYgo_82mh^]3
+!s100 UnzHjY`Z^nHi7Qb`HBUQk1
+R9
+33
+R187
+!i10b 1
+R188
+Z215 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/1/src/pof_uart_regen_1.vhd|
+Z216 !s107 ../../../pof_protocol/1/src/pof_uart_regen_1.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+R2
+R5
+R6
+R127
+l44
+L36
+V37H`m3i_7M4FDk;Pc;co>1
+!s100 BnmZcSDkHK[PZB7d3ZY5?2
+R9
+33
+R187
+!i10b 1
+R188
+R215
+R216
+!i113 1
+R14
+R15
+Epof_uart_rx_0
+R175
+R2
+R5
+R6
+R0
+Z217 8../../../pof_protocol/0/src/pof_uart_rx_0.vhd
+Z218 F../../../pof_protocol/0/src/pof_uart_rx_0.vhd
+l0
+L23
+V4UN=F08B[C66nnRniO`d@1
+!s100 T8TFjg6[QBZ`gN]Rb[lf>1
+R9
+33
+R64
+!i10b 1
+R65
+Z219 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/pof_uart_rx_0.vhd|
+Z220 !s107 ../../../pof_protocol/0/src/pof_uart_rx_0.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+R2
+R5
+R6
+R183
+l48
+L38
+VJ4]OZRUYM7Png8?2DUPfT1
+!s100 RFl2_cnfNN8keGM4OHDh91
+R9
+33
+R64
+!i10b 1
+R65
+R219
+R220
+!i113 1
+R14
+R15
+Epof_uart_rx_1
+R184
+R2
+R5
+R6
+R0
+Z221 8../../../pof_protocol/1/src/pof_uart_rx_1.vhd
+Z222 F../../../pof_protocol/1/src/pof_uart_rx_1.vhd
+l0
+L23
+VIdB@T2OTYenXR:eYN[0i51
+!s100 Vb9GV3IXAK;zf4dg_ITR`2
+R9
+33
+R187
+!i10b 1
+R188
+Z223 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/1/src/pof_uart_rx_1.vhd|
+Z224 !s107 ../../../pof_protocol/1/src/pof_uart_rx_1.vhd|
+!i113 1
+R14
+R15
+Artl
+R106
+R2
+R5
+R6
+R191
+l48
+L38
+V1QjE^F2[JV<:f03n7o[kZ2
+!s100 zfSczV[J?6jihcR]LDY@N2
+R9
+33
+R187
+!i10b 1
+R188
+R223
+R224
+!i113 1
+R14
+R15
+Epulse_generator_3
+Z225 w1608021865
+R131
+R3
+R2
+R5
+R6
+R0
+Z226 8../../../pulse_generator/3/src/pulse_generator_3.vhd
+Z227 F../../../pulse_generator/3/src/pulse_generator_3.vhd
+l0
+L35
+V[mDV^NlTb3jVWQVdYR8>73
+!s100 eQDUhlOGUIMj>7UC_kF_U0
+R9
+33
+R156
+!i10b 1
+R162
+Z228 !s90 -reportprogress|300|-2008|-work|work|../../../pulse_generator/3/src/pulse_generator_3.vhd|
+Z229 !s107 ../../../pulse_generator/3/src/pulse_generator_3.vhd|
+!i113 1
+R14
+R15
+Artl
+Z230 DEx4 work 17 simple_frac_div_3 0 22 [FER3QWD8geo5JX7gBzjZ3
+R159
+R165
+Z231 DEx4 work 15 queue_and_delay 0 22 LhiPj@S6neQdSeLizH9@Jg:D[i0
+R9
+33
+R10
+!i10b 1
+R11
+R234
+R235
+!i113 1
+R14
+R15
+Eseb_epd_led_gen_6
+Z236 w1608021827
+R2
+R5
+R6
+R0
+Z237 8../src/seb_epd_led_gen_6.vhd
+Z238 F../src/seb_epd_led_gen_6.vhd
+l0
+L23
+Va>zgG1jzSBcj3O0
+R9
+33
+R45
+!i10b 1
+R46
+R252
+R253
+!i113 1
+R14
+R15
+Esync_fifo
+R31
+R2
+R3
+R5
+R6
+R0
+Z254 8../../../common/0/src/altera/sync_fifo.vhd
+Z255 F../../../common/0/src/altera/sync_fifo.vhd
+l0
+L44
+VN]YPQB<=CP`NBW9hN2]Nj2
+!s100 YYUM7@GA]YVkRmTZ;b`5a2
+R9
+33
+R10
+!i10b 1
+R11
+Z256 !s90 -reportprogress|300|-2008|-work|work|../../../common/0/src/altera/sync_fifo.vhd|
+Z257 !s107 ../../../common/0/src/altera/sync_fifo.vhd|
+!i113 1
+R14
+R15
+Asyn
+R2
+R3
+R5
+R6
+R105
+l97
+L62
+Vm9z:_R3DH=EE0An`Ag1SD1
+!s100 1am[WmU<<_7ga=K7OWYX50
+R9
+33
+R10
+!i10b 1
+R11
+R256
+R257
+!i113 1
+R14
+R15
+Esync_reset
+Z258 w1608021787
+R5
+R6
+R0
+Z259 8../../../common/0/src/sync_reset.vhd
+Z260 F../../../common/0/src/sync_reset.vhd
+l0
+L24
+Vc[<]h2fVQC4UPNR8zn7iJ2
+!s100 TXESP;?`4D0R`mXX`FmOb1
+R9
+33
+R34
+!i10b 1
+R35
+Z261 !s90 -reportprogress|300|-2008|-work|work|../../../common/0/src/sync_reset.vhd|
+Z262 !s107 ../../../common/0/src/sync_reset.vhd|
+!i113 1
+R14
+R15
+Artl
+R5
+R6
+R134
+l35
+L31
+VU[RCj:E>`SL:5m22
+!s100 O2FKOLCoDSfA?:NcQ=XIQ3
+R9
+33
+R34
+!i10b 1
+R35
+Z265 !s90 -reportprogress|300|-2008|-work|work|../../../common/0/src/sync_wire.vhd|
+Z266 !s107 ../../../common/0/src/sync_wire.vhd|
+!i113 1
+R14
+R15
+Artl
+R5
+R6
+R106
+l38
+L34
+Vm=aVcAEKTZ`Cg6@YMIDfS0
+!s100 ^2jJQh^6LPNkMWoZOEi^[2
+R9
+33
+R34
+!i10b 1
+R35
+R265
+R266
+!i113 1
+R14
+R15
+Esync_wire_redge
+R258
+R5
+R6
+R0
+Z267 8../../../common/0/src/sync_wire_rEdge.vhd
+Z268 F../../../common/0/src/sync_wire_rEdge.vhd
+l0
+L23
+Vi`Y_eUL[MQ07R1kFeezIK2
+!s100 IK81;j2>cW5iaGUK<9T=L2
+R9
+33
+R34
+!i10b 1
+R35
+Z269 !s90 -reportprogress|300|-2008|-work|work|../../../common/0/src/sync_wire_rEdge.vhd|
+Z270 !s107 ../../../common/0/src/sync_wire_rEdge.vhd|
+!i113 1
+R14
+R15
+Artl
+R5
+R6
+R182
+l39
+L34
+VEl?^lgmBZYS4K2T^^V[Z63
+!s100 eCRkcjikDSWB?Ag@GEY2F3
+R9
+33
+R34
+!i10b 1
+R35
+R269
+R270
+!i113 1
+R14
+R15
+Euart_tx_0
+Z271 w1608021846
+R2
+R5
+R6
+R0
+Z272 8../../../pof_protocol/0/src/uart_tx_0.vhd
+Z273 F../../../pof_protocol/0/src/uart_tx_0.vhd
+l0
+L23
+V;G>MOOB[D3G]R>4`Sn0DU1
+!s100 G5JIZEob^6TLc]9_DOeKl1
+R9
+33
+R178
+!i10b 1
+R179
+Z274 !s90 -reportprogress|300|-2008|-work|work|../../../pof_protocol/0/src/uart_tx_0.vhd|
+Z275 !s107 ../../../pof_protocol/0/src/uart_tx_0.vhd|
+!i113 1
+R14
+R15
+Artl
+R2
+R5
+R6
+R199
+l52
+L37
+VS[XiiMiIIcB^0icW62
+R9
+33
+R178
+!i10b 1
+R179
+R274
+R275
+!i113 1
+R14
+R15
+Euart_tx_1
+Z276 w1608021852
+R2
+R5
+R6
+R0
+Z277 8../../../pof_protocol/1/src/uart_tx_1.vhd
+Z278 F../../../pof_protocol/1/src/uart_tx_1.vhd
+l0
+L23
+Vkaambe?K;_NOW@a`SKl6f0
+!s100 gm4M7nbbQbZi=LY_YL]ddz`_9:BV91
+R9
+33
+R187
+!i10b 1
+R188
+R279
+R280
+!i113 1
+R14
+R15
diff --git a/generic_ip/fire_pulse_manager/7/sim/work/_lib.qdb b/generic_ip/fire_pulse_manager/7/sim/work/_lib.qdb
new file mode 100644
index 0000000..4ed0772
Binary files /dev/null and b/generic_ip/fire_pulse_manager/7/sim/work/_lib.qdb differ
diff --git a/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qdb b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qdb
new file mode 100644
index 0000000..7bfe63e
Binary files /dev/null and b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qdb differ
diff --git a/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qpg b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qpg
new file mode 100644
index 0000000..3d3197a
Binary files /dev/null and b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qpg differ
diff --git a/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qtl b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qtl
new file mode 100644
index 0000000..f1cef86
Binary files /dev/null and b/generic_ip/fire_pulse_manager/7/sim/work/_lib1_0.qtl differ
diff --git a/generic_ip/fire_pulse_manager/7/sim/work/_vmake b/generic_ip/fire_pulse_manager/7/sim/work/_vmake
new file mode 100644
index 0000000..37aa36a
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/sim/work/_vmake
@@ -0,0 +1,4 @@
+m255
+K4
+z0
+cModel Technology
diff --git a/generic_ip/fire_pulse_manager/7/src/fire_pulse_7_pkg.vhd b/generic_ip/fire_pulse_manager/7/src/fire_pulse_7_pkg.vhd
new file mode 100644
index 0000000..50ac28e
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/fire_pulse_7_pkg.vhd
@@ -0,0 +1,38 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_pkg
+-- Project : HMB/EMB/SMB
+-------------------------------------------------------------------------------
+-- File : fire_pulse_pkg.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2017-09-08
+-- Last update: 2020-04-17
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Package for fire_pulse_manager block
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+package fire_pulse_7_pkg is
+
+ -----------------------------------------------------------------------------
+ -- Inner block mapping
+ -----------------------------------------------------------------------------
+
+ constant BLK_SIZE : integer := 2048;
+
+ constant FP_CTRL_ID : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller
+ constant DIAG_BLK_ID : natural := 1; -- Block ID for the Diagnostic Block
+ constant LOG_BLK_ID : natural := 2; -- Block ID for the Event Logger
+ constant INT_ENC_ID : natural := 3; -- Block ID for the Internal Encoder Block
+ constant EMS_BLK_ID : natural := 4; -- Block ID for the EMS block
+ constant POF_BLK_ID : natural := 5; -- Block ID for the POF output interface
+ constant PG_CH_ID : natural := 6; -- Block ID for Pulse-Generator
+
+end package fire_pulse_7_pkg;
diff --git a/generic_ip/fire_pulse_manager/7/src/fire_pulse_ctrl_7.vhd b/generic_ip/fire_pulse_manager/7/src/fire_pulse_ctrl_7.vhd
new file mode 100644
index 0000000..dac10b8
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/fire_pulse_ctrl_7.vhd
@@ -0,0 +1,265 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_ctrl
+-- Project : HMB/EMB/SMB
+-------------------------------------------------------------------------------
+-- File : fire_pulse_ctrl.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2017-09-06
+-- Last update: 2020-05-15
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Control service logic for the Fire-Controller-Manager
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+
+entity fire_pulse_ctrl_7 is
+ port(
+ reset_n : in std_logic;
+ clk : in std_logic;
+ fpm_config : in std_logic_vector(10 downto 0);
+ fpm_init : out std_logic;
+ src_sel : out std_logic_vector(3 downto 0);
+ uart_regen_bypass : out std_logic;
+ enable_rx : out std_logic;
+ error_rate_thres : out std_logic_vector(7 downto 0);
+ max_error_flag : in std_logic;
+ rx_watchdog : in std_logic;
+ rx_watchdog_en : out std_logic;
+ rx_watchdog_clr : out std_logic;
+ parity_err_cnt : in std_logic_vector(15 downto 0);
+ skip_pos_cnt : in std_logic_vector(15 downto 0);
+ pd_cnt : in std_logic_vector(15 downto 0);
+ mon_point_src : in std_logic_vector(15 downto 0);
+ mon_points : out std_logic_vector(3 downto 0);
+ coarse_time : out std_logic_vector(31 downto 0);
+ fine_time : out std_logic_vector(27 downto 0);
+ one_pps : out std_logic;
+ dw_src : out std_logic_vector( 3 downto 0);
+ dw_pulse_width : out std_logic_vector(15 downto 0);
+ led_status : in std_logic_vector(11 downto 0);
+ -- Interrupt Senders
+ ins_fpm_irq_0 : out std_logic;
+ -- Avalon MM Interface
+ avs_address : in std_logic_vector(4 downto 0);
+ avs_write : in std_logic;
+ avs_writedata : in std_logic_vector(31 downto 0);
+ avs_read : in std_logic;
+ avs_readdata : out std_logic_vector(31 downto 0));
+end entity fire_pulse_ctrl_7;
+
+architecture rtl of fire_pulse_ctrl_7 is
+
+ -----------------------------------------------------------------------------
+ -- Constants, Signals
+ -----------------------------------------------------------------------------
+
+ constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to
+ -- make it right
+
+ signal enable_rx_i : std_logic;
+ signal fine_time_wrap, time_ld_en : std_logic;
+ signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic;
+ signal uart_regen_bypass_i : std_logic;
+ signal upd_min_pos_i, upd_max_pos_i : std_logic;
+ signal fpm_init_i, fpm_init_d : std_logic;
+ signal fpm_init_start, fpm_init_done : std_logic;
+ signal fpm_init_done_flag, fpm_init_pulse : std_logic;
+ signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0);
+ signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0);
+ signal src_sel_i, dw_src_i : std_logic_vector( 3 downto 0);
+ signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0);
+ signal bit_div : std_logic_vector( 3 downto 0);
+ signal error_rate_thres_i, init_cnt : std_logic_vector( 7 downto 0);
+ signal dw_pulse_width_i : std_logic_vector(15 downto 0);
+ signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0);
+ signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0);
+
+begin
+
+ pCTRL_REGs : process(reset_n, clk)
+ begin -- process
+ if (reset_n = '0') then
+ fpm_init_i <= '0';
+ fpm_init_d <= '0';
+ fpm_init_done_flag <= '0';
+ init_cnt <= (others => '0');
+ fine_time_i <= (others => '0');
+ coarse_time_i <= (others => '0');
+ elsif (clk = '1' and clk'event) then
+ fpm_init_d <= fpm_init_start;
+ if(fpm_init_start = '1' and fpm_init_d = '0') then
+ fpm_init_done_flag <= '0';
+ elsif(fpm_init_done = '1') then
+ fpm_init_done_flag <= '1';
+ end if;
+ if(fpm_init_pulse = '1') then
+ fpm_init_i <= '1';
+ elsif(fpm_init_done = '1') then
+ fpm_init_i <= '0';
+ end if;
+ if(fpm_init_pulse = '1') then
+ init_cnt <= (others => '0');
+ elsif(fpm_init_i = '1') then
+ init_cnt <= std_logic_vector(unsigned(init_cnt)+1);
+ end if;
+ if (time_ld_en = '1') then
+ fine_time_i <= fine_time_init;
+ elsif (fine_time_wrap = '1') then
+ fine_time_i <= (others => '0');
+ else
+ fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1);
+ end if;
+ if (time_ld_en = '1') then
+ coarse_time_i <= coarse_time_init;
+ elsif (fine_time_wrap = '1') then
+ coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1);
+ end if;
+ one_pps <= fine_time_wrap;
+ end if;
+ end process pCTRL_REGs;
+
+ fpm_init_pulse <= fpm_init_start and fpm_init_d;
+ fpm_init_done <= '1' when unsigned(init_cnt) = 50 else '0';
+
+ fpm_init <= fpm_init_i;
+
+ fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0';
+
+ coarse_time <= coarse_time_i;
+ fine_time <= fine_time_i;
+
+ dw_src <= dw_src_i;
+ dw_pulse_width <= dw_pulse_width_i;
+
+ -- MOnitoring Point selection
+ mon_points(0) <= mon_point_src(to_integer(unsigned(mp_sel0)));
+ mon_points(1) <= mon_point_src(to_integer(unsigned(mp_sel1)));
+ mon_points(2) <= mon_point_src(to_integer(unsigned(mp_sel2)));
+ mon_points(3) <= mon_point_src(to_integer(unsigned(mp_sel3)));
+
+ -----------------------------------------------------------------------------
+ -- IRQ generation and management
+ -----------------------------------------------------------------------------
+
+ pIRQ : process(reset_n, clk)
+ begin
+ if (reset_n = '0') then
+ ins_fpm_irq_0 <= '0';
+ irq <= "0";
+ irq_src_d <= "0";
+ elsif (clk = '1' and clk'event) then
+ irq_src_d <= irq_src;
+ for n in 0 to irq'left loop
+ if (irq_clr(n) = '1') then
+ irq(n) <= '0';
+ elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then
+ irq(n) <= '1';
+ end if;
+ end loop; -- n
+ ins_fpm_irq_0 <= irq_val(0);
+ end if;
+ end process pIRQ;
+
+ irq_val <= irq and not irq_mask;
+ irq_src <= "1" when max_error_flag = '1' or rx_watchdog = '1' else "0";
+
+ -----------------------------------------------------------------------------
+ -- C&S registers
+ -----------------------------------------------------------------------------
+
+ fpm_ctrl_7_csr_regs_i : entity work.fpm_ctrl_7_csr_regs
+ generic map (
+ ADDR_DECODE_WIDTH => 5
+ )
+ port map (
+ -- Clock and reset
+ clk => clk,
+ rst_n => reset_n,
+
+ -- auto-generated
+
+ -- Internal signal ports
+ fpm_init_start => fpm_init_start,
+ signal_selection_fire_pulse_sel => src_sel_i(0),
+ signal_selection_enc_pd_emul_en => src_sel_i(1),
+ signal_selection_seb_epd_en => src_sel_i(2),
+ signal_selection_seb_epd_linkout_sel => src_sel_i(3),
+ pof_receiver_control_pof_rx_enable => enable_rx_i,
+ pof_receiver_control_uart_regeneration_bypass => uart_regen_bypass_i,
+ pof_receiver_control_clear_max => open,
+ pof_receiver_control_clear_min => open,
+ pof_receiver_control_uart_rx_div => open,
+ monitoring_point_selection_mp0 => mp_sel0,
+ monitoring_point_selection_mp1 => mp_sel1,
+ monitoring_point_selection_mp2 => mp_sel2,
+ monitoring_point_selection_mp3 => mp_sel3,
+ coarse_time_init => coarse_time_init,
+ fine_time_init_fine_time_init => fine_time_init,
+ fine_time_init_time_load_en => time_ld_en,
+ pof_rx_control_w_error_rate_thres => error_rate_thres_i,
+ pof_rx_control_w_rx_watchdog_en => rx_watchdog_en_i,
+ pof_rx_control_w_rx_watchdog_clr => rx_watchdog_clr_i,
+ fpm_interrupt_irq_en => irq_en(0),
+ fpm_interrupt_irq_clr => irq_clr(0),
+ fpm_interrupt_irq_mask => irq_mask(0),
+ drop_watch_config_dw_src => dw_src_i,
+ drop_watch_config_dw_pulse_width => dw_pulse_width_i,
+ fpm_config_ch_num => fpm_config(3 downto 0),
+ fpm_config_seb_epd_logic_present => fpm_config(4),
+ fpm_config_smb_diagnostic_present => fpm_config(5),
+ fpm_config_event_logger_present => fpm_config(6),
+ fpm_config_pof_protocol_version => fpm_config(7),
+ fpm_config_delay_equalization_enable => fpm_config(8),
+ fpm_config_tof_comp_enable => fpm_config(9),
+ fpm_config_pixel_pitch_corr_enable => fpm_config(10),
+ fpm_init_done => fpm_init_done_flag,
+ fine_time_status => fine_time_i,
+ coarse_time_status => coarse_time_i,
+ pof_rx_status_parity_bit_error_count => parity_err_cnt,
+ pof_rx_status_skipped_position_error_count => skip_pos_cnt,
+ pof_rx_control_r_rx_watchdog => rx_watchdog,
+ pof_rx_control_r_rx_error_flag => max_error_flag,
+ irq_status => irq_val(0),
+ pd_cnt => pd_cnt,
+ seb_epd_led_status_led_pd_g => led_status(0),
+ seb_epd_led_status_led_pd_y => led_status(1),
+ seb_epd_led_status_led_pd_r => led_status(2),
+ seb_epd_led_status_led_enc_p1_g => led_status(3),
+ seb_epd_led_status_led_enc_p1_y => led_status(4),
+ seb_epd_led_status_led_enc_p1_r => led_status(5),
+ seb_epd_led_status_led_enc_p2_g => led_status(6),
+ seb_epd_led_status_led_enc_p2_y => led_status(7),
+ seb_epd_led_status_led_enc_p2_r => led_status(8),
+ seb_epd_led_status_led_pof_in_g => led_status(9),
+ seb_epd_led_status_led_pof_in_y => led_status(10),
+ seb_epd_led_status_led_pof_in_r => led_status(11),
+
+ -- end auto-generated
+
+ -- Slave bus port
+ avs_address => avs_address(4 downto 0),
+ avs_write => avs_write,
+ avs_writedata => avs_writedata,
+ avs_read => avs_read,
+ avs_readdata => avs_readdata
+
+ );
+
+ src_sel <= src_sel_i;
+ enable_rx <= enable_rx_i;
+ uart_regen_bypass <= uart_regen_bypass_i;
+
+ error_rate_thres <= error_rate_thres_i;
+ rx_watchdog_en <= rx_watchdog_en_i;
+ rx_watchdog_clr <= rx_watchdog_clr_i;
+
+end architecture rtl;
diff --git a/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_6.vhd b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_6.vhd
new file mode 100644
index 0000000..a37f1c7
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_6.vhd
@@ -0,0 +1,948 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_manager
+-- Project : HMB/EMB/SMB
+-------------------------------------------------------------------------------
+-- File : fire_pulse_manager.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2017-09-06
+-- Last update: 2020-05-19
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Generates fire request from the EMS output data
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.common_pkg.all;
+use work.fire_pulse_6_pkg.all;
+
+entity fire_pulse_manager_6 is
+ generic (
+ SEB_EPD_MODE : boolean := false; -- Support SEB-EPD
+ CH_NUM : integer range 1 to 15 := 4; -- number of Pulse-Generator blocks
+ PD_QUEUE_SIZE : natural := 512;
+ ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block
+ ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block
+ LOG_FIFO_SIZE : natural range 256 to 4096 := 1024;
+ POF_PROT_VER : natural range 0 to 1 := 0; -- POF-Protocol Versions:
+ -- 0 => Standard, 1 => Add Print-Start
+ PULSE_DELAY_EQUAL_EN : boolean := false;
+ TOF_COMP_EN : boolean := false;
+ PIXEL_PITCH_CORR_EN : boolean := false);
+ port(
+ reset_n : in std_logic;
+ clk : in std_logic; -- 100MHz
+ rx_clk : in std_logic; -- 300MHz (typical)
+ -- Datapath I/Os
+ pof_rx : in std_logic;
+ pof_tx : out std_logic;
+ pof_iso_en : out std_logic;
+ seb_epd_mode_en : out std_logic;
+ seb_epd_enc_p1 : in std_logic;
+ seb_epd_enc_p2 : in std_logic;
+ seb_epd_pd : in std_logic;
+ fire_pulse : out std_logic_vector(32*CH_NUM - 1 downto 0);
+ start_of_image : out std_logic_vector(32*CH_NUM - 1 downto 0);
+ stream_busy_a : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0');
+ stream_busy_b : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0');
+ dp_dir_out : out std_logic_vector(CH_NUM - 1 downto 0);
+ abs_pos_out : out std_logic_vector(31 downto 0);
+ print_start : out std_logic;
+ mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points
+ -- on header J7
+ -- Interrupt Senders
+ ins_fpm_irq_0 : out std_logic;
+ ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_6(rtl)"
+ ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_6(rtl)"
+ ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_6(rtl)"
+ -- Avalon MM (Slave) Interface
+ avs_address : in std_logic_vector(14 downto 0);
+ avs_write : in std_logic;
+ avs_writedata : in std_logic_vector(31 downto 0);
+ avs_read : in std_logic;
+ avs_waitrequest : out std_logic;
+ avs_readdata : out std_logic_vector(31 downto 0));
+end entity fire_pulse_manager_6;
+
+architecture rtl of fire_pulse_manager_6 is
+
+ -- Period used for Time-of-Flight compensation velocity measurememnt
+ constant VEL_MEAS_PERIOD : natural := 10000;
+
+ constant POF_UART_BIT_BIV : integer := 6; -- POF-Rx UART sampling clock vs
+ -- baudrate ratio
+
+ constant BLK_NUM : natural := 6 + CH_NUM;
+
+ signal reset_n_i : std_logic;
+ --
+ signal cs_addr : std_logic_vector(10 downto 0);
+ signal cs_write_en : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_write_data : std_logic_vector(31 downto 0);
+ signal cs_read_en : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_read_valid : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_read_data : std_logic_vector(32 * BLK_NUM - 1 downto 0);
+ --
+ signal cs_ctrl_write_en : std_logic;
+ signal cs_ctrl_read_en : std_logic;
+ signal cs_ctrl_read_valid : std_logic;
+ signal cs_ctrl_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_pg_write_en : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_en : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_valid : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_data : std_logic_vector(32 * CH_NUM - 1 downto 0);
+ --
+ signal cs_diag_write_en : std_logic;
+ signal cs_diag_read_en : std_logic;
+ signal cs_diag_read_valid : std_logic;
+ signal cs_diag_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_log_write_en : std_logic;
+ signal cs_log_read_en : std_logic;
+ signal cs_log_read_valid : std_logic;
+ signal cs_log_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_ie_write_en : std_logic;
+ signal cs_ie_read_en : std_logic;
+ signal cs_ie_read_valid : std_logic;
+ signal cs_ie_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_ems_write_en : std_logic;
+ signal cs_ems_read_en : std_logic;
+ signal cs_ems_read_valid : std_logic;
+ signal cs_ems_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_pof_write_en : std_logic;
+ signal cs_pof_read_en : std_logic;
+ signal cs_pof_read_valid : std_logic;
+ signal cs_pof_read_data : std_logic_vector(31 downto 0);
+ --
+ signal enable_rx : std_logic;
+ signal uart_regen_bypass : std_logic;
+ signal max_error_flag : std_logic;
+ signal rx_watchdog : std_logic;
+ signal rx_watchdog_en : std_logic;
+ signal rx_watchdog_clr : std_logic;
+ signal print_start_i : std_logic;
+ signal dw_src : std_logic_vector( 3 downto 0);
+ signal error_rate_thres : std_logic_vector( 7 downto 0);
+ signal parity_err_cnt : std_logic_vector(15 downto 0);
+ signal skip_pos_cnt : std_logic_vector(15 downto 0);
+ signal mon_point_src : std_logic_vector(15 downto 0);
+ signal dw_pulse_width : std_logic_vector(15 downto 0);
+ signal fine_time : std_logic_vector(27 downto 0);
+ signal coarse_time : std_logic_vector(31 downto 0);
+ --
+ signal init, remote_init : std_logic;
+ signal dp_dir : std_logic_vector(CH_NUM - 1 downto 0);
+ signal set_pos_ie : std_logic;
+ signal enc_pulse : std_logic_vector(CH_NUM - 1 downto 0);
+ signal pd_pulse : std_logic;
+ signal pd_pulse_ie : std_logic;
+ signal pd_pulse_pof : std_logic;
+ signal pd_ems : std_logic;
+ --
+ signal inc_pos : std_logic;
+ signal inc_pos_pof : std_logic;
+ signal inc_pos_ie : std_logic;
+ signal inc_pos_ems : std_logic;
+ signal dec_pos : std_logic;
+ signal dec_pos_pof : std_logic;
+ signal dec_pos_ie : std_logic;
+ signal dec_pos_ems : std_logic;
+ signal abs_pos : std_logic_vector(31 downto 0);
+ signal abs_pos_pof : std_logic_vector(31 downto 0);
+ signal abs_pos_ems : std_logic_vector(31 downto 0);
+ signal abs_pos_ie : std_logic_vector(39 downto 0);
+ --
+ signal pd_pulse_mux : std_logic;
+ signal enc_p1_mux : std_logic;
+ signal enc_p2_mux : std_logic;
+ signal enc_p1_ie : std_logic;
+ signal enc_p2_ie : std_logic;
+ signal ems_filt_pd : std_logic;
+ signal ems_filt_p1 : std_logic;
+ signal ems_filt_p2 : std_logic;
+ --
+ signal pof_tx_regen : std_logic;
+ signal pof_tx_data : std_logic;
+ signal dw_pulse : std_logic;
+ signal dw_pulse_i : std_logic;
+ signal rst_dw_pulse : std_logic;
+ signal set_dw_pulse : std_logic;
+ signal dw_trigger : std_logic;
+ signal dw_trigger_d : std_logic;
+ signal dw_pulse_cnt : std_logic_vector(15 downto 0);
+ --
+ signal pd_cnt : std_logic_vector(15 downto 0);
+ --
+ type fire_pulse_t is array (0 to CH_NUM-1) of std_logic_vector(31 downto 0);
+ signal ch_fire_pulse : fire_pulse_t;
+ signal ch_start_of_image : fire_pulse_t;
+ signal ch_pd : std_logic_vector(CH_NUM - 1 downto 0);
+ signal ch_raw_pulse, ch_mask : std_logic_vector(CH_NUM - 1 downto 0);
+ signal src_sel : std_logic_vector(3 downto 0);
+ signal fpm_init : std_logic;
+ --
+ signal ext_fp_in_sync : std_logic;
+ signal ext_fp_in : std_logic;
+ signal ext_fp_in_d : std_logic;
+ signal ext_fp : std_logic;
+ --
+ type vel_samp_per_vec_t is array (0 to CH_NUM-1) of std_logic_vector(19 downto 0);
+ signal vel_meas : std_logic_vector(19 downto 0);
+ signal vel_sampling_per : vel_samp_per_vec_t;
+ --
+ signal one_pps : std_logic;
+ signal log_data_src : std_logic_vector(31 downto 0);
+ --
+ signal led_pd_g : std_logic;
+ signal led_pd_y : std_logic;
+ signal led_pd_r : std_logic;
+ signal led_enc_p1_g : std_logic;
+ signal led_enc_p1_y : std_logic;
+ signal led_enc_p1_r : std_logic;
+ signal led_enc_p2_g : std_logic;
+ signal led_enc_p2_y : std_logic;
+ signal led_enc_p2_r : std_logic;
+ signal led_pof_g : std_logic;
+ signal led_pof_y : std_logic;
+ signal led_pof_r : std_logic;
+ signal led_status : std_logic_vector(11 downto 0);
+ --
+ signal fpm_generic_status : std_logic_vector(10 downto 0);
+
+begin
+
+ -----------------------------------------------------------------------------
+ -- Synchronize the input reset (h2f_reset) to the clock (from PLL)
+ -----------------------------------------------------------------------------
+
+ iSyncReset : entity work.sync_reset
+ port map(
+ async_rstN => reset_n,
+ clk => clk,
+ sync_rstN => reset_n_i);
+
+
+ -----------------------------------------------------------------------------
+ -- C&S Register Interface Splitting
+ -----------------------------------------------------------------------------
+
+ iCS_BUS_ITF : entity work.cs_bus_ift
+ generic map(
+ BLK_NUM => BLK_NUM)
+ port map(
+ rstN => reset_n_i,
+ clk => clk,
+ avs_address => avs_address(14 downto 0),
+ avs_write => avs_write,
+ avs_writedata => avs_writedata,
+ avs_read => avs_read,
+ avs_waitrequest => avs_waitrequest,
+ avs_readdata => avs_readdata,
+ cs_addr => cs_addr,
+ cs_we => cs_write_en,
+ cs_wr_data => cs_write_data,
+ cs_re => cs_read_en,
+ cs_rv => cs_read_valid,
+ cs_rd_data => cs_read_data);
+
+ cs_ctrl_write_en <= cs_write_en(FP_CTRL_ID);
+ cs_diag_write_en <= cs_write_en(DIAG_BLK_ID);
+ cs_log_write_en <= cs_write_en(LOG_BLK_ID);
+ cs_ie_write_en <= cs_write_en(INT_ENC_ID);
+ cs_ems_write_en <= cs_write_en(EMS_BLK_ID);
+ cs_pof_write_en <= cs_write_en(POF_BLK_ID);
+ cs_pg_write_en_g : for i in 1 to CH_NUM generate
+ cs_pg_write_en(i - 1) <= cs_write_en(PG_CH_ID + i - 1);
+ end generate;
+
+ cs_ctrl_read_en <= cs_read_en(FP_CTRL_ID);
+ cs_diag_read_en <= cs_read_en(DIAG_BLK_ID);
+ cs_log_read_en <= cs_read_en(LOG_BLK_ID);
+ cs_ie_read_en <= cs_read_en(INT_ENC_ID);
+ cs_ems_read_en <= cs_read_en(EMS_BLK_ID);
+ cs_pof_read_en <= cs_read_en(POF_BLK_ID);
+ cs_pg_read_en_g : for i in 1 to CH_NUM generate
+ cs_pg_read_en(i - 1) <= cs_read_en(PG_CH_ID + i - 1);
+ end generate;
+
+ cs_read_valid(FP_CTRL_ID) <= cs_ctrl_read_valid;
+ cs_read_valid(DIAG_BLK_ID) <= cs_diag_read_valid;
+ cs_read_valid(LOG_BLK_ID) <= cs_log_read_valid;
+ cs_read_valid(INT_ENC_ID) <= cs_ie_read_valid;
+ cs_read_valid(EMS_BLK_ID) <= cs_ems_read_valid;
+ cs_read_valid(POF_BLK_ID) <= cs_pof_read_valid;
+ cs_read_valid_pg_g : for i in 1 to CH_NUM generate
+ cs_read_valid(PG_CH_ID + i - 1) <= cs_pg_read_valid(i - 1);
+ end generate;
+
+ cs_read_data(31 + 32 * FP_CTRL_ID downto 32 * FP_CTRL_ID) <= cs_ctrl_read_data;
+ cs_read_data(31 + 32 * DIAG_BLK_ID downto 32 * DIAG_BLK_ID) <= cs_diag_read_data;
+ cs_read_data(31 + 32 * LOG_BLK_ID downto 32 * LOG_BLK_ID) <= cs_log_read_data;
+ cs_read_data(31 + 32 * INT_ENC_ID downto 32 * INT_ENC_ID) <= cs_ie_read_data;
+ cs_read_data(31 + 32 * EMS_BLK_ID downto 32 * EMS_BLK_ID) <= cs_ems_read_data;
+ cs_read_data(31 + 32 * POF_BLK_ID downto 32 * POF_BLK_ID) <= cs_pof_read_data;
+ cs_read_data_pg_g : for i in 1 to CH_NUM generate
+ cs_read_data(31 + 32 * (PG_CH_ID + i - 1) downto 32 * (PG_CH_ID + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1));
+ end generate;
+
+ -----------------------------------------------------------------------------
+ -- Fire-Pulse-Manager Controller
+ -----------------------------------------------------------------------------
+
+ iCTRL : entity work.fire_pulse_ctrl_6
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ fpm_config => fpm_generic_status,
+ fpm_init => fpm_init,
+ src_sel => src_sel,
+ uart_regen_bypass => uart_regen_bypass,
+ enable_rx => enable_rx,
+ error_rate_thres => error_rate_thres,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt,
+ pd_cnt => pd_cnt,
+ mon_point_src => mon_point_src,
+ mon_points => mon_pt,
+ coarse_time => coarse_time,
+ fine_time => fine_time,
+ one_pps => one_pps,
+ dw_src => dw_src,
+ dw_pulse_width => dw_pulse_width,
+ led_status => led_status,
+ ins_fpm_irq_0 => ins_fpm_irq_0,
+ avs_address => cs_addr(4 downto 0),
+ avs_write => cs_ctrl_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ctrl_read_en,
+ avs_readdatavalid => cs_ctrl_read_valid,
+ avs_readdata => cs_ctrl_read_data);
+
+ fpm_generic_status( 3 downto 0) <= std_logic_vector(to_unsigned(CH_NUM, 4));
+ fpm_generic_status(4) <= '1' when SEB_EPD_MODE = true else '0';
+ fpm_generic_status(5) <= '1' when ADD_SMB_DIAG = true else '0';
+ fpm_generic_status(6) <= '1' when ADD_EVENT_LOGGER = true else '0';
+ fpm_generic_status(7) <= '1' when POF_PROT_VER = 1 else '0';
+ fpm_generic_status(8) <= '1' when PULSE_DELAY_EQUAL_EN = true else '0';
+ fpm_generic_status(9) <= '1' when TOF_COMP_EN = true else '0';
+ fpm_generic_status(10) <= '1' when PIXEL_PITCH_CORR_EN = true else '0';
+
+
+ -----------------------------------------------------------------------------
+ -- I/Os selection
+ -----------------------------------------------------------------------------
+
+ pENC_PD_SRC_SEL : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ -- Abs-Pos and PD source selection
+ if(src_sel(2) = '1') then
+ -- Use SEB-EPD inputs
+ pd_pulse <= pd_ems;
+ abs_pos <= abs_pos_ems;
+ inc_pos <= inc_pos_ems;
+ dec_pos <= dec_pos_ems;
+ else
+ if(src_sel(1) = '0') then
+ pd_pulse <= pd_pulse_pof;
+ abs_pos <= abs_pos_pof;
+ inc_pos <= inc_pos_pof;
+ dec_pos <= dec_pos_pof;
+ else
+ pd_pulse <= pd_pulse_ie;
+ abs_pos <= abs_pos_ie(31 downto 0);
+ inc_pos <= inc_pos_ie;
+ dec_pos <= dec_pos_ie;
+ end if;
+ end if;
+ end if;
+ end process pENC_PD_SRC_SEL;
+
+ gPOF_TX_OUT : if SEB_EPD_MODE = true generate
+
+ pof_tx <= dw_pulse when src_sel(3) = '1' else
+ pof_tx_regen when src_sel(2) = '0' else
+ pof_tx_data;
+
+ pBUF_SEB_EPD_MODE : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ seb_epd_mode_en <= src_sel(2);
+ end if;
+ end process pBUF_SEB_EPD_MODE;
+
+ else generate
+
+ pof_tx <= pof_tx_regen;
+
+ seb_epd_mode_en <= '0';
+
+ end generate gPOF_TX_OUT;
+
+ pBUF_OUT : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ abs_pos_out <= abs_pos;
+ dp_dir_out <= dp_dir;
+ for i in 0 to CH_NUM-1 loop
+ if(src_sel(0) = '1') then
+ fire_pulse(i*32+31 downto i*32) <= ch_fire_pulse(i);
+ start_of_image(i*32+31 downto i*32) <= ch_start_of_image(i);
+ else
+ fire_pulse(i*32+31 downto i*32) <= (others => ext_fp);
+ start_of_image(i*32+31 downto i*32) <= (others => '0');
+ end if;
+ end loop; -- i
+ print_start <= print_start_i;
+ end if;
+ end process pBUF_OUT;
+
+ pINIT_GEN : process(clk)
+ begin
+ if(clk = '1' and clk'Event) then
+ if(src_sel(1) = '0') then
+ init <= fpm_init or (not src_sel(2) and (not enable_rx or remote_init));
+ else
+ init <= fpm_init or set_pos_ie;
+ end if;
+ end if;
+ end process pINIT_GEN;
+
+ mon_point_src(0) <= init;
+ mon_point_src(1) <= dp_dir(0);
+ mon_point_src(2) <= pd_pulse;
+ mon_point_src(3) <= enc_pulse(0);
+ mon_point_src(4) <= ch_pd(0);
+ mon_point_src(5) <= ch_fire_pulse(0)(0);
+ mon_point_src(6) <= ch_raw_pulse(0);
+ mon_point_src(7) <= ch_mask(0);
+ mon_point_src(8) <= pof_rx;
+ mon_point_src(9) <= ch_fire_pulse(0)(0);
+ mon_point_src(10) <= ch_start_of_image(0)(0);
+ mon_point_src(11) <= inc_pos;
+ mon_point_src(12) <= dec_pos;
+ mon_point_src(13) <= print_start_i;
+ --
+ mon_point_src(15 downto 14) <= (others => '0');
+
+ pof_iso_en <= enable_rx;
+
+ -----------------------------------------------------------------------------
+ -- PD Counter
+ -----------------------------------------------------------------------------
+
+ pPD_CNT : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(init = '1') then
+ pd_cnt <= (others => '0');
+ elsif(pd_pulse = '1') then
+ pd_cnt <= std_logic_vector(unsigned(pd_cnt) + 1);
+ end if;
+ end if;
+ end process pPD_CNT;
+
+ -----------------------------------------------------------------------------
+ -- Encoder Speed Detection
+ -----------------------------------------------------------------------------
+
+ gENC_VEL: if TOF_COMP_EN = true generate
+
+ -- Used for Time-of-Flight Compensation
+ iVEL : entity work.simple_enc_vel_detect_6
+ port map (
+ clk => clk,
+ init => init,
+ step_pos => inc_pos,
+ step_neg => dec_pos,
+ sampling_period => vel_sampling_per(0),
+ vel_meas => vel_meas);
+
+ else generate
+
+ vel_meas <= (others => '0');
+
+ end generate gENC_VEL;
+
+ -----------------------------------------------------------------------------
+ -- Pulse Generator
+ -----------------------------------------------------------------------------
+
+ pulse_generator_g : for i in 0 to CH_NUM-1 generate
+ iCH_PG : entity work.pulse_generator_3
+ generic map(
+ PD_QUEUE_SIZE => PD_QUEUE_SIZE,
+ PULSE_DELAY_EQUAL_EN => PULSE_DELAY_EQUAL_EN,
+ SPITTING_EN => false,
+ BIDIR_CH_OFFSET_EN => false,
+ DIAG_COUNTERS => true,
+ TOF_COMP_EN => TOF_COMP_EN,
+ PIXEL_PITCH_CORR_EN => PIXEL_PITCH_CORR_EN)
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ init => init,
+ pd_in => pd_pulse,
+ abs_position => abs_pos,
+ enc_vel => vel_meas,
+ enc_speed_meas_w => vel_sampling_per(i),
+ dp_dir => dp_dir(i),
+ fire_req_vec => ch_fire_pulse(i),
+ start_of_image_vec => ch_start_of_image(i),
+ stream_busy_a => stream_busy_a(i),
+ stream_busy_b => stream_busy_b(i),
+ ch_pd => ch_pd(i),
+ ch_mask => ch_mask(i),
+ raw_fire_req => ch_raw_pulse(i),
+ enc_pulse => enc_pulse(i),
+ avs_address => cs_addr(10 downto 0),
+ avs_write => cs_pg_write_en(i),
+ avs_writedata => cs_write_data,
+ avs_read => cs_pg_read_en(i),
+ avs_readdatavalid => cs_pg_read_valid(i),
+ avs_readdata => cs_pg_read_data(31 + 32*i downto 32*i));
+ end generate;
+
+ -----------------------------------------------------------------------------
+ -- POF Rx Interface
+ -----------------------------------------------------------------------------
+
+ gPOF: if POF_PROT_VER = 0 generate
+
+ -- POF Receiver
+ iPOF_RX : entity work.pof_rx_0
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV)
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ init => '0',
+ rx_clk => rx_clk,
+ rx_data => pof_rx,
+ init_out => remote_init,
+ pd_out => pd_pulse_pof,
+ inc_pos => inc_pos_pof,
+ dec_pos => dec_pos_pof,
+ abs_pos => abs_pos_pof,
+ enable => enable_rx,
+ error_rate_thres => error_rate_thres,
+ one_pps => one_pps,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt);
+
+ -- UART signal regeneration
+ iUART_REGEN : entity work.pof_uart_regen_0
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV,
+ data_width => 8)
+ port map(
+ reset_n => reset_n,
+ clk => rx_clk,
+ enable => enable_rx,
+ bypass_en => uart_regen_bypass,
+ uart_rx => pof_rx,
+ uart_tx => pof_tx_regen);
+
+ print_start_i <= '0';
+
+ elsif POF_PROT_VER = 1 generate
+
+ -- POF Receiver
+ iPOF_RX : entity work.pof_rx_1
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV)
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ init => '0',
+ rx_clk => rx_clk,
+ rx_data => pof_rx,
+ init_out => remote_init,
+ pd_out => pd_pulse_pof,
+ print_start => print_start_i,
+ inc_pos => inc_pos_pof,
+ dec_pos => dec_pos_pof,
+ abs_pos => abs_pos_pof,
+ enable => enable_rx,
+ error_rate_thres => error_rate_thres,
+ one_pps => one_pps,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt);
+
+ -- UART signal regeneration
+ iUART_REGEN : entity work.pof_uart_regen_1
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV,
+ data_width => 9)
+ port map(
+ reset_n => reset_n,
+ clk => rx_clk,
+ enable => enable_rx,
+ bypass_en => uart_regen_bypass,
+ uart_rx => pof_rx,
+ uart_tx => pof_tx);
+
+ end generate gPOF;
+
+ -----------------------------------------------------------------------------
+ -- EMS
+ -----------------------------------------------------------------------------
+
+ gEMS : if SEB_EPD_MODE = true generate
+
+ iEMS : entity work.ems_0
+ generic map(
+ ADD_ENC_ZP_LOGIC => false,
+ ADD_MULT_DEBUG_REG => false,
+ GEN_PRINT_START => false)
+ port map (
+ clk => clk,
+ reset_n => reset_n_i,
+ init => init,
+ avs_address => cs_addr(3 downto 0),
+ avs_write => cs_ems_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ems_read_en,
+ avs_readdatavalid => cs_ems_read_valid,
+ avs_readdata => cs_ems_read_data,
+ rs422_pd => pd_pulse_mux,
+ rs422_p1 => enc_p1_mux,
+ rs422_p2 => enc_p2_mux,
+ rs422_zp => '0',
+ ttl_pd => '0',
+ ttl_pd_npn => '0',
+ ttl_p1 => '0',
+ ttl_p2 => '0',
+ ttl_zp => '0',
+ abs_position => abs_pos_ems,
+ pd_out => pd_ems,
+ print_start => open,
+ set_pos => open,
+ inc_pos => inc_pos_ems,
+ dec_pos => dec_pos_ems,
+ filt_p1 => ems_filt_p1,
+ filt_p2 => ems_filt_p2,
+ filt_zp => open,
+ filt_pd => ems_filt_pd);
+
+ pd_pulse_mux <= seb_epd_pd when src_sel(1) = '0' else pd_pulse_ie;
+ enc_p1_mux <= seb_epd_enc_p1 when src_sel(1) = '0' else enc_p1_ie;
+ enc_p2_mux <= seb_epd_enc_p2 when src_sel(1) = '0' else enc_p2_ie;
+
+ else generate
+
+ pEMS_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_ems_read_valid <= cs_ems_read_en;
+ end if;
+ end process pEMS_RD;
+
+ cs_ems_read_data <= X"DEAD_BEEF";
+
+ abs_pos_ems <= (others => '0');
+ pd_ems <= '0';
+ inc_pos_ems <= '0';
+ dec_pos_ems <= '0';
+
+ end generate gEMS;
+
+ -----------------------------------------------------------------------------
+ -- POF-Tx
+ -----------------------------------------------------------------------------
+
+ gPOF_TX : if SEB_EPD_MODE = true generate
+ -- Default POF-Protocol
+ iPOF_TX: entity work.pof_tx_0
+ port map (
+ reset_n => reset_n_i,
+ clk => clk,
+ init => init,
+ pd_in => pd_ems,
+ inc_pos => inc_pos_ems,
+ dec_pos => dec_pos_ems,
+ abs_position => abs_pos_ems,
+ tx_data => pof_tx_data,
+ avs_address => cs_addr(2 downto 0),
+ avs_write => cs_pof_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_pof_read_en,
+ avs_readdatavalid => cs_pof_read_valid,
+ avs_readdata => cs_pof_read_data);
+
+ else generate
+
+ pPOF_TX_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_pof_read_valid <= cs_pof_read_en;
+ end if;
+ end process pPOF_TX_RD;
+
+ cs_pof_read_data <= X"DEAD_BEEF";
+
+ pof_tx_data <= '0';
+
+ end generate gPOF_TX;
+
+ -----------------------------------------------------------------------------
+ -- SEB-EPD LEDs
+ -----------------------------------------------------------------------------
+
+ gSEB_EPD_LEDs : if SEB_EPD_MODE = true generate
+ iLED_GEN: entity work.seb_epd_led_gen_6
+ port map (
+ reset_n => reset_n,
+ clk => clk,
+ init => init,
+ pd => ems_filt_pd,
+ enc_p1 => ems_filt_p1,
+ enc_p2 => ems_filt_p2,
+ pof => pof_rx,
+ all_ok => '1',
+ led_pd_g => led_pd_g,
+ led_pd_y => led_pd_y,
+ led_pd_r => led_pd_r,
+ led_enc_p1_g => led_enc_p1_g,
+ led_enc_p1_y => led_enc_p1_y,
+ led_enc_p1_r => led_enc_p1_r,
+ led_enc_p2_g => led_enc_p2_g,
+ led_enc_p2_y => led_enc_p2_y,
+ led_enc_p2_r => led_enc_p2_r,
+ led_pof_g => led_pof_g,
+ led_pof_y => led_pof_y,
+ led_pof_r => led_pof_r);
+
+ led_status( 2 downto 0) <= led_pd_r & led_pd_y & led_pd_g;
+ led_status( 5 downto 3) <= led_enc_p1_r & led_enc_p1_y & led_enc_p1_g;
+ led_status( 8 downto 6) <= led_enc_p2_r & led_enc_p2_y & led_enc_p2_g;
+ led_status(11 downto 9) <= led_pof_r & led_pof_y & led_pof_g;
+
+ else generate
+
+ led_status <= (others => '0');
+
+ end generate gSEB_EPD_LEDs;
+
+ -----------------------------------------------------------------------------
+ -- Diagnostic block
+ -----------------------------------------------------------------------------
+
+ gDIAG: if ADD_SMB_DIAG = false generate
+
+ pDIAG_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_diag_read_valid <= cs_diag_read_en;
+ end if;
+ end process pDIAG_RD;
+
+ cs_diag_read_data <= X"DEAD_BEEF";
+
+ ins_fpm_irq_1 <= '0';
+ ins_fpm_irq_2 <= '0';
+ ins_fpm_irq_3 <= '0';
+
+ elsif ADD_SMB_DIAG = true generate
+
+ iDiagnostic : entity work.smb_diagnostics_6
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ ext_diag_rst => init,
+ rs422_phase0 => seb_epd_enc_p1,
+ rs422_phase1 => seb_epd_enc_p2,
+ rs422_zero_ph => '0',
+ rs422_prod_det => seb_epd_pd,
+ ttl_phase0 => '0',
+ ttl_phase1 => '0',
+ ttl_zero_ph => '0',
+ ttl_prod_det => '0',
+ ttl_prod_det_npn => '0',
+ filt_phase0 => ems_filt_p1,
+ filt_phase1 => ems_filt_p2,
+ filt_zero_ph => '0',
+ filt_prod_det => pd_pulse,
+ enc_out => enc_pulse(0),
+ pd_out => ch_pd(0),
+ pos_step => inc_pos,
+ neg_step => dec_pos,
+ drop_watch => '0',
+ fire_req => ch_fire_pulse(0)(0),
+ fine_time => fine_time,
+ coarse_time => coarse_time,
+ abs_position => open,
+ ins_diag_irq_0 => ins_fpm_irq_1,
+ ins_diag_irq_1 => ins_fpm_irq_2,
+ ins_diag_irq_2 => ins_fpm_irq_3,
+ avs_address => cs_addr(5 downto 0),
+ avs_write => cs_diag_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_diag_read_en,
+ avs_readdatavalid => cs_diag_read_valid,
+ avs_readdata => cs_diag_read_data);
+
+ end generate gDIAG;
+
+ -----------------------------------------------------------------------------
+ -- Event Logger
+ -----------------------------------------------------------------------------
+
+ gEL: if ADD_EVENT_LOGGER = false generate
+
+ pLOGGER_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_log_read_valid <= cs_log_read_en;
+ end if;
+ end process pLOGGER_RD;
+
+ cs_log_read_data <= X"DEAD_BEEF";
+
+ elsif ADD_EVENT_LOGGER = true generate
+
+ event_logger_0_1: entity work.event_logger_0
+ generic map (
+ FIFO_SIZE => LOG_FIFO_SIZE)
+ port map (
+ rstN => reset_n_i,
+ clk => clk,
+ data_src => log_data_src,
+ fine_time => fine_time,
+ abs_position => abs_pos,
+ ins_irq => open,
+ avs_address => cs_addr(3 downto 0),
+ avs_write => cs_log_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_log_read_en,
+ avs_readdatavalid => cs_log_read_valid,
+ avs_readdata => cs_log_read_data);
+
+ log_data_src(0) <= init;
+ log_data_src(1) <= dp_dir(0);
+ log_data_src(2) <= pd_pulse;
+ log_data_src(3) <= enc_pulse(0);
+ log_data_src(4) <= ch_pd(0);
+ log_data_src(5) <= ch_fire_pulse(0)(0);
+ log_data_src(6) <= ch_raw_pulse(0);
+ log_data_src(7) <= ch_mask(0);
+ log_data_src(8) <= pof_rx;
+ log_data_src(9) <= ch_fire_pulse(0)(0);
+ log_data_src(10) <= ch_start_of_image(0)(0);
+ log_data_src(11) <= inc_pos;
+ log_data_src(12) <= dec_pos;
+ log_data_src(13) <= print_start_i;
+ --
+ log_data_src(31 downto 14) <= (others => '0');
+
+ end generate gEL;
+
+ -----------------------------------------------------------------------------
+ -- Ext fire pulse detection
+ -----------------------------------------------------------------------------
+
+ -- just filter all the pulses with a width less than 200 ns
+ pEXT_PULSE_DETECT : process(clk)
+ variable pulse_width_cnt : std_logic_vector(4 downto 0);
+ variable pulse_cnt_en : std_logic := '0';
+ begin
+ if(clk = '1' and clk'event) then
+ ext_fp_in_sync <= pof_rx;
+ ext_fp_in <= ext_fp_in_sync;
+ ext_fp <= '0';
+ ext_fp_in_d <= ext_fp_in;
+ if(ext_fp_in = '1' and ext_fp_in_d = '0') then
+ pulse_cnt_en := '1';
+ pulse_width_cnt := (others => '0');
+ elsif(pulse_cnt_en = '1' and ext_fp_in_d = '1') then
+ if(unsigned(pulse_width_cnt) = 19) then
+ pulse_cnt_en := '0';
+ ext_fp <= '1';
+ else
+ pulse_width_cnt := std_logic_vector(unsigned(pulse_width_cnt)+1);
+ end if;
+ end if;
+ end if;
+ end process pEXT_PULSE_DETECT;
+
+ -----------------------------------------------------------------------------
+ -- Drop-Watch Pulse generation
+ -----------------------------------------------------------------------------
+
+ pGEN_DW: process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ dw_trigger_d <= dw_trigger;
+ if(rst_dw_pulse = '1') then
+ dw_pulse_i <= '0';
+ elsif(set_dw_pulse = '1') then
+ dw_pulse_i <= '1';
+ end if;
+ if(rst_dw_pulse = '1') then
+ dw_pulse_cnt <= (0 => '1', others => '0');
+ elsif(dw_pulse_i = '1') then
+ dw_pulse_cnt <= std_logic_vector(unsigned(dw_pulse_cnt) + 1);
+ end if;
+ end if;
+ end process pGEN_DW;
+
+ dw_trigger <= ch_fire_pulse(to_integer(unsigned(dw_src(log2(CH_NUM)-1 downto 0))))(0);
+
+ rst_dw_pulse <= '1' when init = '1' or unsigned(dw_pulse_cnt) = unsigned(dw_pulse_width) else '0';
+ set_dw_pulse <= dw_trigger and not dw_trigger_d;
+
+ dw_pulse <= dw_pulse_i;
+
+ -----------------------------------------------------------------------------
+ -- Internal encoder generator
+ -----------------------------------------------------------------------------
+
+ iEMUL : entity work.enc_pd_emul_1
+ generic map(
+ SEQ_ENABLE => false)
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ ttl_pd => open,
+ ttl_enc_p1 => open,
+ ttl_enc_p2 => open,
+ ttl_enc_zp => open,
+ rs422_pd => pd_pulse_ie,
+ rs422_enc_p1 => enc_p1_ie,
+ rs422_enc_p2 => enc_p2_ie,
+ rs422_enc_zp => open,
+ abs_pos_out => abs_pos_ie,
+ set_pos_out => set_pos_ie,
+ inc_pos_out => inc_pos_ie,
+ dec_pos_out => dec_pos_ie,
+ avs_address => cs_addr(9 downto 0),
+ avs_write => cs_ie_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ie_read_en,
+ avs_readdatavalid => cs_ie_read_valid,
+ avs_readdata => cs_ie_read_data);
+
+end architecture rtl;
diff --git a/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd
new file mode 100644
index 0000000..b39f212
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd
@@ -0,0 +1,955 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_manager
+-- Project : HMB/EMB/SMB
+-------------------------------------------------------------------------------
+-- File : fire_pulse_manager.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2017-09-06
+-- Last update: 2020-05-19
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Generates fire request from the EMS output data
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.common_pkg.all;
+use work.fire_pulse_7_pkg.all;
+
+entity fire_pulse_manager_7 is
+ generic (
+ SEB_EPD_MODE : boolean := false; -- Support SEB-EPD
+ CH_NUM : integer range 1 to 15 := 4; -- number of Pulse-Generator blocks
+ PD_QUEUE_SIZE : natural := 512;
+ ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block
+ ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block
+ LOG_FIFO_SIZE : natural range 256 to 4096 := 1024;
+ POF_PROT_VER : natural range 0 to 1 := 0; -- POF-Protocol Versions:
+ -- 0 => Standard, 1 => Add Print-Start
+ PULSE_DELAY_EQUAL_EN : boolean := false;
+ TOF_COMP_EN : boolean := false;
+ PIXEL_PITCH_CORR_EN : boolean := false);
+ port(
+ reset_n : in std_logic;
+ clk : in std_logic; -- 100MHz
+ rx_clk : in std_logic; -- 300MHz (typical)
+ -- Datapath I/Os
+ pof_rx : in std_logic;
+ pof_tx : out std_logic;
+ pof_iso_en : out std_logic;
+ seb_epd_mode_en : out std_logic;
+ seb_epd_enc_p1 : in std_logic;
+ seb_epd_enc_p2 : in std_logic;
+ seb_epd_pd : in std_logic;
+ fire_pulse : out std_logic_vector(32*CH_NUM - 1 downto 0);
+ start_of_image : out std_logic_vector(32*CH_NUM - 1 downto 0);
+ stream_busy_a : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0');
+ stream_busy_b : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0');
+ dp_dir_out : out std_logic_vector(CH_NUM - 1 downto 0);
+ abs_pos_out : out std_logic_vector(31 downto 0);
+ print_start : out std_logic;
+ mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points
+ -- on header J7
+ -- Interrupt Senders
+ ins_fpm_irq_0 : out std_logic;
+ ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_6(rtl)"
+ ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_6(rtl)"
+ ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_6(rtl)"
+ -- Avalon MM (Slave) Interface
+ avs_address : in std_logic_vector(14 downto 0);
+ avs_write : in std_logic;
+ avs_writedata : in std_logic_vector(31 downto 0);
+ avs_read : in std_logic;
+ avs_waitrequest : out std_logic;
+ avs_readdata : out std_logic_vector(31 downto 0));
+end entity fire_pulse_manager_7;
+
+architecture rtl of fire_pulse_manager_7 is
+
+ -- Period used for Time-of-Flight compensation velocity measurememnt
+ constant VEL_MEAS_PERIOD : natural := 10000;
+
+ constant POF_UART_BIT_BIV : integer := 6; -- POF-Rx UART sampling clock vs
+ -- baudrate ratio
+
+ constant BLK_NUM : natural := 6 + CH_NUM;
+
+ signal reset_n_i : std_logic;
+ --
+ signal cs_addr : std_logic_vector(10 downto 0);
+ signal cs_write_en : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_write_data : std_logic_vector(31 downto 0);
+ signal cs_read_en : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_read_valid : std_logic_vector(BLK_NUM - 1 downto 0);
+ signal cs_read_data : std_logic_vector(32 * BLK_NUM - 1 downto 0);
+ --
+ signal cs_ctrl_write_en : std_logic;
+ signal cs_ctrl_read_en : std_logic;
+ signal cs_ctrl_read_valid : std_logic;
+ signal cs_ctrl_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_pg_write_en : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_en : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_valid : std_logic_vector(CH_NUM - 1 downto 0);
+ signal cs_pg_read_data : std_logic_vector(32 * CH_NUM - 1 downto 0);
+ --
+ signal cs_diag_write_en : std_logic;
+ signal cs_diag_read_en : std_logic;
+ signal cs_diag_read_valid : std_logic;
+ signal cs_diag_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_log_write_en : std_logic;
+ signal cs_log_read_en : std_logic;
+ signal cs_log_read_valid : std_logic;
+ signal cs_log_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_ie_write_en : std_logic;
+ signal cs_ie_read_en : std_logic;
+ signal cs_ie_read_valid : std_logic;
+ signal cs_ie_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_ems_write_en : std_logic;
+ signal cs_ems_read_en : std_logic;
+ signal cs_ems_read_valid : std_logic;
+ signal cs_ems_read_data : std_logic_vector(31 downto 0);
+ --
+ signal cs_pof_write_en : std_logic;
+ signal cs_pof_read_en : std_logic;
+ signal cs_pof_read_valid : std_logic;
+ signal cs_pof_read_data : std_logic_vector(31 downto 0);
+ --
+ signal enable_rx : std_logic;
+ signal uart_regen_bypass : std_logic;
+ signal max_error_flag : std_logic;
+ signal rx_watchdog : std_logic;
+ signal rx_watchdog_en : std_logic;
+ signal rx_watchdog_clr : std_logic;
+ signal print_start_i : std_logic;
+ signal dw_src : std_logic_vector( 3 downto 0);
+ signal error_rate_thres : std_logic_vector( 7 downto 0);
+ signal parity_err_cnt : std_logic_vector(15 downto 0);
+ signal skip_pos_cnt : std_logic_vector(15 downto 0);
+ signal mon_point_src : std_logic_vector(15 downto 0);
+ signal dw_pulse_width : std_logic_vector(15 downto 0);
+ signal fine_time : std_logic_vector(27 downto 0);
+ signal coarse_time : std_logic_vector(31 downto 0);
+ --
+ signal init, remote_init : std_logic;
+ signal dp_dir : std_logic_vector(CH_NUM - 1 downto 0);
+ signal set_pos_ie : std_logic;
+ signal enc_pulse : std_logic_vector(CH_NUM - 1 downto 0);
+ signal pd_pulse : std_logic;
+ signal pd_pulse_ie : std_logic;
+ signal pd_pulse_pof : std_logic;
+ signal pd_ems : std_logic;
+ --
+ signal inc_pos : std_logic;
+ signal inc_pos_pof : std_logic;
+ signal inc_pos_ie : std_logic;
+ signal inc_pos_ems : std_logic;
+ signal dec_pos : std_logic;
+ signal dec_pos_pof : std_logic;
+ signal dec_pos_ie : std_logic;
+ signal dec_pos_ems : std_logic;
+ signal abs_pos : std_logic_vector(31 downto 0);
+ signal abs_pos_pof : std_logic_vector(31 downto 0);
+ signal abs_pos_ems : std_logic_vector(31 downto 0);
+ signal abs_pos_ie : std_logic_vector(39 downto 0);
+ --
+ signal pd_pulse_mux : std_logic;
+ signal enc_p1_mux : std_logic;
+ signal enc_p2_mux : std_logic;
+ signal enc_p1_ie : std_logic;
+ signal enc_p2_ie : std_logic;
+ signal ems_filt_pd : std_logic;
+ signal ems_filt_p1 : std_logic;
+ signal ems_filt_p2 : std_logic;
+ --
+ signal pof_tx_regen : std_logic;
+ signal pof_tx_data : std_logic;
+ signal dw_pulse : std_logic;
+ signal dw_pulse_i : std_logic;
+ signal rst_dw_pulse : std_logic;
+ signal set_dw_pulse : std_logic;
+ signal dw_trigger : std_logic;
+ signal dw_trigger_d : std_logic;
+ signal dw_pulse_cnt : std_logic_vector(15 downto 0);
+ --
+ signal pd_cnt : std_logic_vector(15 downto 0);
+ --
+ type fire_pulse_t is array (0 to CH_NUM-1) of std_logic_vector(31 downto 0);
+ signal ch_fire_pulse : fire_pulse_t;
+ signal ch_start_of_image : fire_pulse_t;
+ signal ch_pd : std_logic_vector(CH_NUM - 1 downto 0);
+ signal ch_raw_pulse, ch_mask : std_logic_vector(CH_NUM - 1 downto 0);
+ signal src_sel : std_logic_vector(3 downto 0);
+ signal fpm_init : std_logic;
+ --
+ signal ext_fp_in_sync : std_logic;
+ signal ext_fp_in : std_logic;
+ signal ext_fp_in_d : std_logic;
+ signal ext_fp : std_logic;
+ --
+ type vel_samp_per_vec_t is array (0 to CH_NUM-1) of std_logic_vector(19 downto 0);
+ signal vel_meas : std_logic_vector(19 downto 0);
+ signal vel_sampling_per : vel_samp_per_vec_t;
+ --
+ signal one_pps : std_logic;
+ signal log_data_src : std_logic_vector(31 downto 0);
+ --
+ signal led_pd_g : std_logic;
+ signal led_pd_y : std_logic;
+ signal led_pd_r : std_logic;
+ signal led_enc_p1_g : std_logic;
+ signal led_enc_p1_y : std_logic;
+ signal led_enc_p1_r : std_logic;
+ signal led_enc_p2_g : std_logic;
+ signal led_enc_p2_y : std_logic;
+ signal led_enc_p2_r : std_logic;
+ signal led_pof_g : std_logic;
+ signal led_pof_y : std_logic;
+ signal led_pof_r : std_logic;
+ signal led_status : std_logic_vector(11 downto 0);
+ --
+ signal fpm_generic_status : std_logic_vector(10 downto 0);
+
+begin
+
+ -----------------------------------------------------------------------------
+ -- Synchronize the input reset (h2f_reset) to the clock (from PLL)
+ -----------------------------------------------------------------------------
+
+ iSyncReset : entity work.sync_reset
+ port map(
+ async_rstN => reset_n,
+ clk => clk,
+ sync_rstN => reset_n_i);
+
+
+ -----------------------------------------------------------------------------
+ -- C&S Register Interface Splitting
+ -----------------------------------------------------------------------------
+
+ iCS_BUS_ITF : entity work.cs_bus_ift
+ generic map(
+ BLK_NUM => BLK_NUM)
+ port map(
+ rstN => reset_n_i,
+ clk => clk,
+ avs_address => avs_address(14 downto 0),
+ avs_write => avs_write,
+ avs_writedata => avs_writedata,
+ avs_read => avs_read,
+ avs_waitrequest => avs_waitrequest,
+ avs_readdata => avs_readdata,
+ cs_addr => cs_addr,
+ cs_we => cs_write_en,
+ cs_wr_data => cs_write_data,
+ cs_re => cs_read_en,
+ cs_rv => cs_read_valid,
+ cs_rd_data => cs_read_data);
+
+ cs_ctrl_write_en <= cs_write_en(FP_CTRL_ID);
+ cs_diag_write_en <= cs_write_en(DIAG_BLK_ID);
+ cs_log_write_en <= cs_write_en(LOG_BLK_ID);
+ cs_ie_write_en <= cs_write_en(INT_ENC_ID);
+ cs_ems_write_en <= cs_write_en(EMS_BLK_ID);
+ cs_pof_write_en <= cs_write_en(POF_BLK_ID);
+ cs_pg_write_en_g : for i in 1 to CH_NUM generate
+ cs_pg_write_en(i - 1) <= cs_write_en(PG_CH_ID + i - 1);
+ end generate;
+
+ cs_ctrl_read_en <= cs_read_en(FP_CTRL_ID);
+ cs_diag_read_en <= cs_read_en(DIAG_BLK_ID);
+ cs_log_read_en <= cs_read_en(LOG_BLK_ID);
+ cs_ie_read_en <= cs_read_en(INT_ENC_ID);
+ cs_ems_read_en <= cs_read_en(EMS_BLK_ID);
+ cs_pof_read_en <= cs_read_en(POF_BLK_ID);
+ cs_pg_read_en_g : for i in 1 to CH_NUM generate
+ cs_pg_read_en(i - 1) <= cs_read_en(PG_CH_ID + i - 1);
+ end generate;
+
+ cs_read_valid(FP_CTRL_ID) <= cs_ctrl_read_valid;
+ cs_read_valid(DIAG_BLK_ID) <= cs_diag_read_valid;
+ cs_read_valid(LOG_BLK_ID) <= cs_log_read_valid;
+ cs_read_valid(INT_ENC_ID) <= cs_ie_read_valid;
+ cs_read_valid(EMS_BLK_ID) <= cs_ems_read_valid;
+ cs_read_valid(POF_BLK_ID) <= cs_pof_read_valid;
+ cs_read_valid_pg_g : for i in 1 to CH_NUM generate
+ cs_read_valid(PG_CH_ID + i - 1) <= cs_pg_read_valid(i - 1);
+ end generate;
+
+ cs_read_data(31 + 32 * FP_CTRL_ID downto 32 * FP_CTRL_ID) <= cs_ctrl_read_data;
+ cs_read_data(31 + 32 * DIAG_BLK_ID downto 32 * DIAG_BLK_ID) <= cs_diag_read_data;
+ cs_read_data(31 + 32 * LOG_BLK_ID downto 32 * LOG_BLK_ID) <= cs_log_read_data;
+ cs_read_data(31 + 32 * INT_ENC_ID downto 32 * INT_ENC_ID) <= cs_ie_read_data;
+ cs_read_data(31 + 32 * EMS_BLK_ID downto 32 * EMS_BLK_ID) <= cs_ems_read_data;
+ cs_read_data(31 + 32 * POF_BLK_ID downto 32 * POF_BLK_ID) <= cs_pof_read_data;
+ cs_read_data_pg_g : for i in 1 to CH_NUM generate
+ cs_read_data(31 + 32 * (PG_CH_ID + i - 1) downto 32 * (PG_CH_ID + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1));
+ end generate;
+
+ -----------------------------------------------------------------------------
+ -- Fire-Pulse-Manager Controller
+ -----------------------------------------------------------------------------
+
+ iCTRL : entity work.fire_pulse_ctrl_7
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ fpm_config => fpm_generic_status,
+ fpm_init => fpm_init,
+ src_sel => src_sel,
+ uart_regen_bypass => uart_regen_bypass,
+ enable_rx => enable_rx,
+ error_rate_thres => error_rate_thres,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt,
+ pd_cnt => pd_cnt,
+ mon_point_src => mon_point_src,
+ mon_points => mon_pt,
+ coarse_time => coarse_time,
+ fine_time => fine_time,
+ one_pps => one_pps,
+ dw_src => dw_src,
+ dw_pulse_width => dw_pulse_width,
+ led_status => led_status,
+ ins_fpm_irq_0 => ins_fpm_irq_0,
+ avs_address => cs_addr(4 downto 0),
+ avs_write => cs_ctrl_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ctrl_read_en,
+ avs_readdata => cs_ctrl_read_data);
+
+ fpm_generic_status( 3 downto 0) <= std_logic_vector(to_unsigned(CH_NUM, 4));
+ fpm_generic_status(4) <= '1' when SEB_EPD_MODE = true else '0';
+ fpm_generic_status(5) <= '1' when ADD_SMB_DIAG = true else '0';
+ fpm_generic_status(6) <= '1' when ADD_EVENT_LOGGER = true else '0';
+ fpm_generic_status(7) <= '1' when POF_PROT_VER = 1 else '0';
+ fpm_generic_status(8) <= '1' when PULSE_DELAY_EQUAL_EN = true else '0';
+ fpm_generic_status(9) <= '1' when TOF_COMP_EN = true else '0';
+ fpm_generic_status(10) <= '1' when PIXEL_PITCH_CORR_EN = true else '0';
+
+
+ -----------------------------------------------------------------------------
+ -- I/Os selection
+ -----------------------------------------------------------------------------
+
+ pENC_PD_SRC_SEL : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ -- Abs-Pos and PD source selection
+ if(src_sel(2) = '1') then
+ -- Use SEB-EPD inputs
+ pd_pulse <= pd_ems;
+ abs_pos <= abs_pos_ems;
+ inc_pos <= inc_pos_ems;
+ dec_pos <= dec_pos_ems;
+ else
+ if(src_sel(1) = '0') then
+ pd_pulse <= pd_pulse_pof;
+ abs_pos <= abs_pos_pof;
+ inc_pos <= inc_pos_pof;
+ dec_pos <= dec_pos_pof;
+ else
+ pd_pulse <= pd_pulse_ie;
+ abs_pos <= abs_pos_ie(31 downto 0);
+ inc_pos <= inc_pos_ie;
+ dec_pos <= dec_pos_ie;
+ end if;
+ end if;
+ end if;
+ end process pENC_PD_SRC_SEL;
+
+ gPOF_TX_OUT : if SEB_EPD_MODE = true generate
+
+ pof_tx <= dw_pulse when src_sel(3) = '1' else
+ pof_tx_regen when src_sel(2) = '0' else
+ pof_tx_data;
+
+ pBUF_SEB_EPD_MODE : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ seb_epd_mode_en <= src_sel(2);
+ end if;
+ end process pBUF_SEB_EPD_MODE;
+
+ else generate
+
+ pof_tx <= pof_tx_regen;
+
+ seb_epd_mode_en <= '0';
+
+ end generate gPOF_TX_OUT;
+
+ pBUF_OUT : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ abs_pos_out <= abs_pos;
+ dp_dir_out <= dp_dir;
+ for i in 0 to CH_NUM-1 loop
+ if(src_sel(0) = '1') then
+ fire_pulse(i*32+31 downto i*32) <= ch_fire_pulse(i);
+ start_of_image(i*32+31 downto i*32) <= ch_start_of_image(i);
+ else
+ fire_pulse(i*32+31 downto i*32) <= (others => ext_fp);
+ start_of_image(i*32+31 downto i*32) <= (others => '0');
+ end if;
+ end loop; -- i
+ print_start <= print_start_i;
+ end if;
+ end process pBUF_OUT;
+
+ pINIT_GEN : process(clk)
+ begin
+ if(clk = '1' and clk'Event) then
+ if(src_sel(1) = '0') then
+ init <= fpm_init or (not src_sel(2) and (not enable_rx or remote_init));
+ else
+ init <= fpm_init or set_pos_ie;
+ end if;
+ end if;
+ end process pINIT_GEN;
+
+ mon_point_src(0) <= init;
+ mon_point_src(1) <= dp_dir(0);
+ mon_point_src(2) <= pd_pulse;
+ mon_point_src(3) <= enc_pulse(0);
+ mon_point_src(4) <= ch_pd(0);
+ mon_point_src(5) <= ch_fire_pulse(0)(0);
+ mon_point_src(6) <= ch_raw_pulse(0);
+ mon_point_src(7) <= ch_mask(0);
+ mon_point_src(8) <= pof_rx;
+ mon_point_src(9) <= ch_fire_pulse(0)(0);
+ mon_point_src(10) <= ch_start_of_image(0)(0);
+ mon_point_src(11) <= inc_pos;
+ mon_point_src(12) <= dec_pos;
+ mon_point_src(13) <= print_start_i;
+ --
+ mon_point_src(15 downto 14) <= (others => '0');
+
+ pof_iso_en <= enable_rx;
+
+ -----------------------------------------------------------------------------
+ -- PD Counter
+ -----------------------------------------------------------------------------
+
+ pPD_CNT : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(init = '1') then
+ pd_cnt <= (others => '0');
+ elsif(pd_pulse = '1') then
+ pd_cnt <= std_logic_vector(unsigned(pd_cnt) + 1);
+ end if;
+ end if;
+ end process pPD_CNT;
+
+ -----------------------------------------------------------------------------
+ -- Encoder Speed Detection
+ -----------------------------------------------------------------------------
+
+ gENC_VEL: if TOF_COMP_EN = true generate
+
+ -- Used for Time-of-Flight Compensation
+ iVEL : entity work.simple_enc_vel_detect_6
+ port map (
+ clk => clk,
+ init => init,
+ step_pos => inc_pos,
+ step_neg => dec_pos,
+ sampling_period => vel_sampling_per(0),
+ vel_meas => vel_meas);
+
+ else generate
+
+ vel_meas <= (others => '0');
+
+ end generate gENC_VEL;
+
+ -----------------------------------------------------------------------------
+ -- Pulse Generator
+ -----------------------------------------------------------------------------
+
+ pulse_generator_g : for i in 0 to CH_NUM-1 generate
+ iCH_PG : entity work.pulse_generator_3
+ generic map(
+ PD_QUEUE_SIZE => PD_QUEUE_SIZE,
+ PULSE_DELAY_EQUAL_EN => PULSE_DELAY_EQUAL_EN,
+ SPITTING_EN => false,
+ BIDIR_CH_OFFSET_EN => false,
+ DIAG_COUNTERS => true,
+ TOF_COMP_EN => TOF_COMP_EN,
+ PIXEL_PITCH_CORR_EN => PIXEL_PITCH_CORR_EN)
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ init => init,
+ pd_in => pd_pulse,
+ abs_position => abs_pos,
+ enc_vel => vel_meas,
+ enc_speed_meas_w => vel_sampling_per(i),
+ dp_dir => dp_dir(i),
+ fire_req_vec => ch_fire_pulse(i),
+ start_of_image_vec => ch_start_of_image(i),
+ stream_busy_a => stream_busy_a(i),
+ stream_busy_b => stream_busy_b(i),
+ ch_pd => ch_pd(i),
+ ch_mask => ch_mask(i),
+ raw_fire_req => ch_raw_pulse(i),
+ enc_pulse => enc_pulse(i),
+ avs_address => cs_addr(10 downto 0),
+ avs_write => cs_pg_write_en(i),
+ avs_writedata => cs_write_data,
+ avs_read => cs_pg_read_en(i),
+ avs_readdatavalid => cs_pg_read_valid(i),
+ avs_readdata => cs_pg_read_data(31 + 32*i downto 32*i));
+ end generate;
+
+ -----------------------------------------------------------------------------
+ -- POF Rx Interface
+ -----------------------------------------------------------------------------
+
+ gPOF: if POF_PROT_VER = 0 generate
+
+ -- POF Receiver
+ iPOF_RX : entity work.pof_rx_0
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV)
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ init => '0',
+ rx_clk => rx_clk,
+ rx_data => pof_rx,
+ init_out => remote_init,
+ pd_out => pd_pulse_pof,
+ inc_pos => inc_pos_pof,
+ dec_pos => dec_pos_pof,
+ abs_pos => abs_pos_pof,
+ enable => enable_rx,
+ error_rate_thres => error_rate_thres,
+ one_pps => one_pps,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt);
+
+ -- UART signal regeneration
+ iUART_REGEN : entity work.pof_uart_regen_0
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV,
+ data_width => 8)
+ port map(
+ reset_n => reset_n,
+ clk => rx_clk,
+ enable => enable_rx,
+ bypass_en => uart_regen_bypass,
+ uart_rx => pof_rx,
+ uart_tx => pof_tx_regen);
+
+ print_start_i <= '0';
+
+ elsif POF_PROT_VER = 1 generate
+
+ -- POF Receiver
+ iPOF_RX : entity work.pof_rx_1
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV)
+ port map(
+ reset_n => reset_n_i,
+ clk => clk,
+ init => '0',
+ rx_clk => rx_clk,
+ rx_data => pof_rx,
+ init_out => remote_init,
+ pd_out => pd_pulse_pof,
+ print_start => print_start_i,
+ inc_pos => inc_pos_pof,
+ dec_pos => dec_pos_pof,
+ abs_pos => abs_pos_pof,
+ enable => enable_rx,
+ error_rate_thres => error_rate_thres,
+ one_pps => one_pps,
+ max_error_flag => max_error_flag,
+ rx_watchdog => rx_watchdog,
+ rx_watchdog_en => rx_watchdog_en,
+ rx_watchdog_clr => rx_watchdog_clr,
+ parity_err_cnt => parity_err_cnt,
+ skip_pos_cnt => skip_pos_cnt);
+
+ -- UART signal regeneration
+ iUART_REGEN : entity work.pof_uart_regen_1
+ generic map(
+ GEN_BIT_DIV => POF_UART_BIT_BIV,
+ data_width => 9)
+ port map(
+ reset_n => reset_n,
+ clk => rx_clk,
+ enable => enable_rx,
+ bypass_en => uart_regen_bypass,
+ uart_rx => pof_rx,
+ uart_tx => pof_tx);
+
+ end generate gPOF;
+
+ -----------------------------------------------------------------------------
+ -- EMS
+ -----------------------------------------------------------------------------
+
+ gEMS : if SEB_EPD_MODE = true generate
+
+ iEMS : entity work.ems_0
+ generic map(
+ ADD_ENC_ZP_LOGIC => false,
+ ADD_MULT_DEBUG_REG => false,
+ GEN_PRINT_START => false)
+ port map (
+ clk => clk,
+ reset_n => reset_n_i,
+ init => init,
+ avs_address => cs_addr(3 downto 0),
+ avs_write => cs_ems_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ems_read_en,
+ avs_readdatavalid => cs_ems_read_valid,
+ avs_readdata => cs_ems_read_data,
+ rs422_pd => pd_pulse_mux,
+ rs422_p1 => enc_p1_mux,
+ rs422_p2 => enc_p2_mux,
+ rs422_zp => '0',
+ ttl_pd => '0',
+ ttl_pd_npn => '0',
+ ttl_p1 => '0',
+ ttl_p2 => '0',
+ ttl_zp => '0',
+ abs_position => abs_pos_ems,
+ pd_out => pd_ems,
+ print_start => open,
+ set_pos => open,
+ inc_pos => inc_pos_ems,
+ dec_pos => dec_pos_ems,
+ filt_p1 => ems_filt_p1,
+ filt_p2 => ems_filt_p2,
+ filt_zp => open,
+ filt_pd => ems_filt_pd);
+
+ pd_pulse_mux <= seb_epd_pd when src_sel(1) = '0' else pd_pulse_ie;
+ enc_p1_mux <= seb_epd_enc_p1 when src_sel(1) = '0' else enc_p1_ie;
+ enc_p2_mux <= seb_epd_enc_p2 when src_sel(1) = '0' else enc_p2_ie;
+
+ pFPC_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_ctrl_read_valid <= cs_ctrl_read_en;
+ end if;
+ end process pFPC_RD;
+
+ else generate
+
+ pEMS_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_ems_read_valid <= cs_ems_read_en;
+ cs_ctrl_read_valid <= cs_ctrl_read_en;
+ end if;
+ end process pEMS_RD;
+
+ cs_ems_read_data <= X"DEAD_BEEF";
+
+ abs_pos_ems <= (others => '0');
+ pd_ems <= '0';
+ inc_pos_ems <= '0';
+ dec_pos_ems <= '0';
+
+ end generate gEMS;
+
+ -----------------------------------------------------------------------------
+ -- POF-Tx
+ -----------------------------------------------------------------------------
+
+ gPOF_TX : if SEB_EPD_MODE = true generate
+ -- Default POF-Protocol
+ iPOF_TX: entity work.pof_tx_0
+ port map (
+ reset_n => reset_n_i,
+ clk => clk,
+ init => init,
+ pd_in => pd_ems,
+ inc_pos => inc_pos_ems,
+ dec_pos => dec_pos_ems,
+ abs_position => abs_pos_ems,
+ tx_data => pof_tx_data,
+ avs_address => cs_addr(2 downto 0),
+ avs_write => cs_pof_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_pof_read_en,
+ avs_readdatavalid => cs_pof_read_valid,
+ avs_readdata => cs_pof_read_data);
+
+ else generate
+
+ pPOF_TX_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_pof_read_valid <= cs_pof_read_en;
+ end if;
+ end process pPOF_TX_RD;
+
+ cs_pof_read_data <= X"DEAD_BEEF";
+
+ pof_tx_data <= '0';
+
+ end generate gPOF_TX;
+
+ -----------------------------------------------------------------------------
+ -- SEB-EPD LEDs
+ -----------------------------------------------------------------------------
+
+ gSEB_EPD_LEDs : if SEB_EPD_MODE = true generate
+ iLED_GEN: entity work.seb_epd_led_gen_6
+ port map (
+ reset_n => reset_n,
+ clk => clk,
+ init => init,
+ pd => ems_filt_pd,
+ enc_p1 => ems_filt_p1,
+ enc_p2 => ems_filt_p2,
+ pof => pof_rx,
+ all_ok => '1',
+ led_pd_g => led_pd_g,
+ led_pd_y => led_pd_y,
+ led_pd_r => led_pd_r,
+ led_enc_p1_g => led_enc_p1_g,
+ led_enc_p1_y => led_enc_p1_y,
+ led_enc_p1_r => led_enc_p1_r,
+ led_enc_p2_g => led_enc_p2_g,
+ led_enc_p2_y => led_enc_p2_y,
+ led_enc_p2_r => led_enc_p2_r,
+ led_pof_g => led_pof_g,
+ led_pof_y => led_pof_y,
+ led_pof_r => led_pof_r);
+
+ led_status( 2 downto 0) <= led_pd_r & led_pd_y & led_pd_g;
+ led_status( 5 downto 3) <= led_enc_p1_r & led_enc_p1_y & led_enc_p1_g;
+ led_status( 8 downto 6) <= led_enc_p2_r & led_enc_p2_y & led_enc_p2_g;
+ led_status(11 downto 9) <= led_pof_r & led_pof_y & led_pof_g;
+
+ else generate
+
+ led_status <= (others => '0');
+
+ end generate gSEB_EPD_LEDs;
+
+ -----------------------------------------------------------------------------
+ -- Diagnostic block
+ -----------------------------------------------------------------------------
+
+ gDIAG: if ADD_SMB_DIAG = false generate
+
+ pDIAG_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_diag_read_valid <= cs_diag_read_en;
+ end if;
+ end process pDIAG_RD;
+
+ cs_diag_read_data <= X"DEAD_BEEF";
+
+ ins_fpm_irq_1 <= '0';
+ ins_fpm_irq_2 <= '0';
+ ins_fpm_irq_3 <= '0';
+
+ elsif ADD_SMB_DIAG = true generate
+
+ iDiagnostic : entity work.smb_diagnostics_6
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ ext_diag_rst => init,
+ rs422_phase0 => seb_epd_enc_p1,
+ rs422_phase1 => seb_epd_enc_p2,
+ rs422_zero_ph => '0',
+ rs422_prod_det => seb_epd_pd,
+ ttl_phase0 => '0',
+ ttl_phase1 => '0',
+ ttl_zero_ph => '0',
+ ttl_prod_det => '0',
+ ttl_prod_det_npn => '0',
+ filt_phase0 => ems_filt_p1,
+ filt_phase1 => ems_filt_p2,
+ filt_zero_ph => '0',
+ filt_prod_det => pd_pulse,
+ enc_out => enc_pulse(0),
+ pd_out => ch_pd(0),
+ pos_step => inc_pos,
+ neg_step => dec_pos,
+ drop_watch => '0',
+ fire_req => ch_fire_pulse(0)(0),
+ fine_time => fine_time,
+ coarse_time => coarse_time,
+ abs_position => open,
+ ins_diag_irq_0 => ins_fpm_irq_1,
+ ins_diag_irq_1 => ins_fpm_irq_2,
+ ins_diag_irq_2 => ins_fpm_irq_3,
+ avs_address => cs_addr(5 downto 0),
+ avs_write => cs_diag_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_diag_read_en,
+ avs_readdatavalid => cs_diag_read_valid,
+ avs_readdata => cs_diag_read_data);
+
+ end generate gDIAG;
+
+ -----------------------------------------------------------------------------
+ -- Event Logger
+ -----------------------------------------------------------------------------
+
+ gEL: if ADD_EVENT_LOGGER = false generate
+
+ pLOGGER_RD : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ cs_log_read_valid <= cs_log_read_en;
+ end if;
+ end process pLOGGER_RD;
+
+ cs_log_read_data <= X"DEAD_BEEF";
+
+ elsif ADD_EVENT_LOGGER = true generate
+
+ event_logger_0_1: entity work.event_logger_0
+ generic map (
+ FIFO_SIZE => LOG_FIFO_SIZE)
+ port map (
+ rstN => reset_n_i,
+ clk => clk,
+ data_src => log_data_src,
+ fine_time => fine_time,
+ abs_position => abs_pos,
+ ins_irq => open,
+ avs_address => cs_addr(3 downto 0),
+ avs_write => cs_log_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_log_read_en,
+ avs_readdatavalid => cs_log_read_valid,
+ avs_readdata => cs_log_read_data);
+
+ log_data_src(0) <= init;
+ log_data_src(1) <= dp_dir(0);
+ log_data_src(2) <= pd_pulse;
+ log_data_src(3) <= enc_pulse(0);
+ log_data_src(4) <= ch_pd(0);
+ log_data_src(5) <= ch_fire_pulse(0)(0);
+ log_data_src(6) <= ch_raw_pulse(0);
+ log_data_src(7) <= ch_mask(0);
+ log_data_src(8) <= pof_rx;
+ log_data_src(9) <= ch_fire_pulse(0)(0);
+ log_data_src(10) <= ch_start_of_image(0)(0);
+ log_data_src(11) <= inc_pos;
+ log_data_src(12) <= dec_pos;
+ log_data_src(13) <= print_start_i;
+ --
+ log_data_src(31 downto 14) <= (others => '0');
+
+ end generate gEL;
+
+ -----------------------------------------------------------------------------
+ -- Ext fire pulse detection
+ -----------------------------------------------------------------------------
+
+ -- just filter all the pulses with a width less than 200 ns
+ pEXT_PULSE_DETECT : process(clk)
+ variable pulse_width_cnt : std_logic_vector(4 downto 0);
+ variable pulse_cnt_en : std_logic := '0';
+ begin
+ if(clk = '1' and clk'event) then
+ ext_fp_in_sync <= pof_rx;
+ ext_fp_in <= ext_fp_in_sync;
+ ext_fp <= '0';
+ ext_fp_in_d <= ext_fp_in;
+ if(ext_fp_in = '1' and ext_fp_in_d = '0') then
+ pulse_cnt_en := '1';
+ pulse_width_cnt := (others => '0');
+ elsif(pulse_cnt_en = '1' and ext_fp_in_d = '1') then
+ if(unsigned(pulse_width_cnt) = 19) then
+ pulse_cnt_en := '0';
+ ext_fp <= '1';
+ else
+ pulse_width_cnt := std_logic_vector(unsigned(pulse_width_cnt)+1);
+ end if;
+ end if;
+ end if;
+ end process pEXT_PULSE_DETECT;
+
+ -----------------------------------------------------------------------------
+ -- Drop-Watch Pulse generation
+ -----------------------------------------------------------------------------
+
+ pGEN_DW: process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ dw_trigger_d <= dw_trigger;
+ if(rst_dw_pulse = '1') then
+ dw_pulse_i <= '0';
+ elsif(set_dw_pulse = '1') then
+ dw_pulse_i <= '1';
+ end if;
+ if(rst_dw_pulse = '1') then
+ dw_pulse_cnt <= (0 => '1', others => '0');
+ elsif(dw_pulse_i = '1') then
+ dw_pulse_cnt <= std_logic_vector(unsigned(dw_pulse_cnt) + 1);
+ end if;
+ end if;
+ end process pGEN_DW;
+
+ dw_trigger <= ch_fire_pulse(to_integer(unsigned(dw_src(log2(CH_NUM)-1 downto 0))))(0);
+
+ rst_dw_pulse <= '1' when init = '1' or unsigned(dw_pulse_cnt) = unsigned(dw_pulse_width) else '0';
+ set_dw_pulse <= dw_trigger and not dw_trigger_d;
+
+ dw_pulse <= dw_pulse_i;
+
+ -----------------------------------------------------------------------------
+ -- Internal encoder generator
+ -----------------------------------------------------------------------------
+
+ iEMUL : entity work.enc_pd_emul_1
+ generic map(
+ SEQ_ENABLE => false)
+ port map(
+ clk => clk,
+ reset_n => reset_n_i,
+ ttl_pd => open,
+ ttl_enc_p1 => open,
+ ttl_enc_p2 => open,
+ ttl_enc_zp => open,
+ rs422_pd => pd_pulse_ie,
+ rs422_enc_p1 => enc_p1_ie,
+ rs422_enc_p2 => enc_p2_ie,
+ rs422_enc_zp => open,
+ abs_pos_out => abs_pos_ie,
+ set_pos_out => set_pos_ie,
+ inc_pos_out => inc_pos_ie,
+ dec_pos_out => dec_pos_ie,
+ avs_address => cs_addr(9 downto 0),
+ avs_write => cs_ie_write_en,
+ avs_writedata => cs_write_data,
+ avs_read => cs_ie_read_en,
+ avs_readdatavalid => cs_ie_read_valid,
+ avs_readdata => cs_ie_read_data);
+
+end architecture rtl;
diff --git a/generic_ip/fire_pulse_manager/7/src/seb_epd_led_gen_6.vhd b/generic_ip/fire_pulse_manager/7/src/seb_epd_led_gen_6.vhd
new file mode 100644
index 0000000..ae8c439
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/seb_epd_led_gen_6.vhd
@@ -0,0 +1,297 @@
+-------------------------------------------------------------------------------
+-- Title : seb_epd_led_gen_6
+-- Project : SMB
+-------------------------------------------------------------------------------
+-- File : seb_epd_led_gen_6.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2018-08-06
+-- Last update: 2020-04-16
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Generate signals for driving the SMB LEDs.
+-- Note: those signals can still be overwritten by software through the
+-- SMB-Ctrl block.
+-------------------------------------------------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity seb_epd_led_gen_6 is
+ generic(
+ MAX_PERIOD_MS : natural := 1000;
+ GREEN_PERIOD_MS : natural := 200);
+ port(
+ reset_n : in std_logic;
+ clk : in std_logic;
+ -- config
+ init : in std_logic;
+ -- input status signals
+ pd : in std_logic;
+ enc_p1 : in std_logic;
+ enc_p2 : in std_logic;
+ pof : in std_logic;
+ all_ok : in std_logic;
+ -- LEDs outputs values
+ led_pd_g : out std_logic;
+ led_pd_y : out std_logic;
+ led_pd_r : out std_logic;
+ led_enc_p1_g : out std_logic;
+ led_enc_p1_y : out std_logic;
+ led_enc_p1_r : out std_logic;
+ led_enc_p2_g : out std_logic;
+ led_enc_p2_y : out std_logic;
+ led_enc_p2_r : out std_logic;
+ led_pof_g : out std_logic;
+ led_pof_y : out std_logic;
+ led_pof_r : out std_logic);
+end entity seb_epd_led_gen_6;
+
+architecture rtl of seb_epd_led_gen_6 is
+
+ constant END_GREEN_PERIOD_MS : natural := MAX_PERIOD_MS - GREEN_PERIOD_MS;
+
+ signal pd_d, enc_p1_d, enc_p2_d, one_ms_pulse : std_logic;
+ signal pd_cnt_zero_flag, rst_pd_green, pd_red, pd_green : std_logic;
+ signal p1_event, p2_event, p1_cnt_zero_flag : std_logic;
+ signal p2_cnt_zero_flag, pd_event, rst_pof_green : std_logic;
+ signal rst_p1_green, rst_p2_green, p1_red, p2_red : std_logic;
+ signal p1_green, p2_green, pof_green, pof_d : std_logic;
+ signal pof_event, pof_cnt_zero_flag, pof_active : std_logic;
+ signal all_ok_d, alert_cnt_zero_flag : std_logic;
+ signal pd_active, p1_active, p2_active : std_logic;
+ --
+ signal alert_led : std_logic_vector( 3 downto 0);
+ signal pd_cnt, pof_cnt : std_logic_vector( 9 downto 0);
+ signal p1_cnt, p2_cnt, alert_cnt : std_logic_vector( 9 downto 0);
+ signal one_ms_cnt : std_logic_vector(16 downto 0);
+
+begin
+
+ pGEN_1MS_PULSE : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ one_ms_pulse <= '0';
+ one_ms_cnt <= (others => '0');
+ elsif(clk = '1' and clk'event) then
+ if(unsigned(one_ms_cnt) = 100000-1) then
+ one_ms_pulse <= '1';
+ one_ms_cnt <= (others => '0');
+ else
+ one_ms_pulse <= '0';
+ one_ms_cnt <= std_logic_vector(unsigned(one_ms_cnt)+1);
+ end if;
+ end if;
+ end process pGEN_1MS_PULSE;
+
+ -----------------------------------------------------------------------------
+ -- PD LEDs
+ -----------------------------------------------------------------------------
+
+ pPD_LEDs : process(reset_n, clk) is
+ begin -- process
+ if(reset_n = '0') then
+ pd_d <= '0';
+ pd_event <= '0';
+ pd_cnt <= (others => '0');
+ pd_green <= '0';
+ led_pd_y <= '0';
+ led_pd_g <= '0';
+ pd_active <= '0';
+ elsif(clk = '1' and clk'event) then
+ pd_d <= pd;
+ pd_event <= pd xor pd_d;
+ if(init = '1') then
+ pd_cnt <= (others => '0');
+ elsif(pd_event = '1') then
+ pd_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pd_cnt'length));
+ elsif(pd_cnt_zero_flag = '0' and one_ms_pulse = '1') then
+ pd_cnt <= std_logic_vector(unsigned(pd_cnt)-1);
+ end if;
+ if(pd_event = '1') then
+ pd_green <= '1';
+ elsif(rst_pd_green = '1' or init = '1') then
+ pd_green <= '0';
+ end if;
+ led_pd_r <= all_ok and pd_red;
+ led_pd_y <= (all_ok and pd_cnt_zero_flag and pd_active) or alert_led(0);
+ led_pd_g <= all_ok and pd_green;
+ if(pd_event = '1') then
+ pd_active <= '1';
+ end if;
+ end if;
+ end process pPD_LEDs;
+
+ pd_cnt_zero_flag <= '1' when unsigned(pd_cnt) = 0 else '0';
+
+ rst_pd_green <= '1' when one_ms_pulse = '1' and unsigned(pd_cnt) = END_GREEN_PERIOD_MS else '0';
+
+ -- PD red LED is never activated because there is only one PD source
+ pd_red <= '0';
+
+ -----------------------------------------------------------------------------
+ -- Encoder LEDs
+ -----------------------------------------------------------------------------
+
+ pENC_LEDs : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ p1_cnt <= (others => '0');
+ p2_cnt <= (others => '0');
+ p1_red <= '0';
+ p1_green <= '0';
+ p2_red <= '0';
+ p2_green <= '0';
+ p1_active <= '0';
+ p2_active <= '0';
+ elsif(clk = '1' and clk'event) then
+ if(init = '1') then
+ p1_cnt <= (others => '0');
+ elsif(p1_event = '1' and p1_red = '0') then
+ p1_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p1_cnt'length));
+ elsif(p1_cnt_zero_flag = '0' and one_ms_pulse = '1') then
+ p1_cnt <= std_logic_vector(unsigned(p1_cnt)-1);
+ end if;
+ if(init = '1') then
+ p2_cnt <= (others => '0');
+ elsif(p2_event = '1' and p2_red = '0') then
+ p2_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p2_cnt'length));
+ elsif(p2_cnt_zero_flag = '0' and one_ms_pulse = '1') then
+ p2_cnt <= std_logic_vector(unsigned(p2_cnt)-1);
+ end if;
+ if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then
+ p1_red <= '0';
+ elsif(p1_event = '1' and p2_event ='1') then
+ p1_red <= '1';
+ end if;
+ if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then
+ p2_red <= '0';
+ elsif(p2_event = '1' and p1_event ='1') then
+ p2_red <= '1';
+ end if;
+ if(p1_red = '1' or rst_p1_green = '1' or init = '1') then
+ p1_green <= '0';
+ elsif(p1_event = '1') then
+ p1_green <= '1';
+ end if;
+ if(p2_red = '1' or rst_p2_green = '1' or init = '1') then
+ p2_green <= '0';
+ elsif(p2_event = '1') then
+ p2_green <= '1';
+ end if;
+ if(p1_event = '1') then
+ p1_active <= '1';
+ end if;
+ if(p2_event = '1') then
+ p2_active <= '1';
+ end if;
+ end if;
+ end process pENC_LEDs;
+
+ pENC_LEDs_NR : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ enc_p1_d <= enc_p1;
+ enc_p2_d <= enc_p2;
+ p1_event <= enc_p1 xor enc_p1_d;
+ p2_event <= enc_p2 xor enc_p2_d;
+ led_enc_p1_r <= all_ok and p1_red;
+ led_enc_p1_y <= (all_ok and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1);
+ led_enc_p1_g <= all_ok and p1_green and not p1_red;
+ led_enc_p2_r <= all_ok and p2_red;
+ led_enc_p2_y <= (all_ok and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2);
+ led_enc_p2_g <= all_ok and p2_green and not p2_red;
+ end if;
+ end process pENC_LEDs_NR;
+
+ p1_cnt_zero_flag <= '1' when unsigned(p1_cnt) = 0 else '0';
+ p2_cnt_zero_flag <= '1' when unsigned(p2_cnt) = 0 else '0';
+
+ rst_p1_green <= '1' when unsigned(p1_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0';
+ rst_p2_green <= '1' when unsigned(p2_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0';
+
+ -----------------------------------------------------------------------------
+ -- POF LEDs
+ -----------------------------------------------------------------------------
+
+ pPOF_LED : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ pof_cnt <= (others => '0');
+ pof_d <= '0';
+ pof_green <= '0';
+ led_pof_g <= '0';
+ led_pof_y <= '0';
+ pof_event <= '0';
+ pof_active <= '0';
+ elsif(clk = '1' and clk'event) then
+ pof_d <= pof;
+ pof_event <= pof and not pof_d;
+ if(init = '1') then
+ pof_cnt <= (others => '0');
+ elsif(pof_event = '1') then
+ pof_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pof_cnt'length));
+ elsif(pof_cnt_zero_flag = '0' and one_ms_pulse = '1') then
+ pof_cnt <= std_logic_vector(unsigned(pof_cnt)-1);
+ end if;
+ if(init = '1' or (rst_pof_green = '1' and pof_event = '0')) then
+ pof_green <= '0';
+ elsif(pof_event = '1') then
+ pof_green <= '1';
+ end if;
+ led_pof_g <= all_ok and pof_green;
+ led_pof_y <= (all_ok and pof_cnt_zero_flag and pof_active) or alert_led(3);
+ if(pof_event = '1') then
+ pof_active <= '1';
+ end if;
+ end if;
+ end process pPOF_LED;
+
+ pof_cnt_zero_flag <= '1' when unsigned(pof_cnt) = 0 else '0';
+
+ rst_pof_green <= '1' when one_ms_pulse = '1' and unsigned(pof_cnt) = END_GREEN_PERIOD_MS else '0';
+
+ led_pof_r <= '0';
+
+
+ -----------------------------------------------------------------------------
+ -- Emergency Flashing
+ -----------------------------------------------------------------------------
+
+ -- when the smb_ctrl watchdog is triggered (all_ok deasserted), all the LEDs
+ -- need to start flashing
+
+ pEMERGENCY_FLASH : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ all_ok_d <= '0';
+ alert_led <= "0000";
+ alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
+ elsif(clk = '1' and clk'event) then
+ all_ok_d <= all_ok;
+ if(all_ok = '1') then
+ alert_led <= "0000";
+ elsif(all_ok = '0' and all_ok_d = '1') then
+ alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
+ else
+ if(alert_cnt_zero_flag = '1') then
+ if(alert_led = "1111") then
+ alert_led <= "0000";
+ else
+ alert_led <= alert_led(2 downto 0) & '1';
+ end if;
+ alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
+ elsif(one_ms_pulse = '1') then
+ alert_cnt <= std_logic_vector(unsigned(alert_cnt)-1);
+ end if;
+ end if;
+ end if;
+ end process pEMERGENCY_FLASH;
+
+ alert_cnt_zero_flag <= '1' when unsigned(alert_cnt) = 0 else '0';
+
+
+end architecture rtl;
diff --git a/generic_ip/fire_pulse_manager/7/src/simple_enc_vel_detect_6.vhd b/generic_ip/fire_pulse_manager/7/src/simple_enc_vel_detect_6.vhd
new file mode 100644
index 0000000..fb2cc49
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/simple_enc_vel_detect_6.vhd
@@ -0,0 +1,76 @@
+-------------------------------------------------------------------------------
+-- Title : simple encoder velocity detection
+-- Project : project independent
+-------------------------------------------------------------------------------
+-- File : simple_enc_vel_detect_6.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2019-06-18
+-- Last update: 2020-04-16
+-- SVN ID : Git
+-- Standard : VHDL'2008
+-------------------------------------------------------------------------------
+-- Description:
+-- This block detects encoder velocity by measuring the balance of encoder
+-- positive and negative steps over consecutive sampling periods.
+-- The sampling period is supposed to be less than 2 ms
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity simple_enc_vel_detect_6 is
+ port (
+ clk : in std_logic; -- Must be 100 MHz
+ init : in std_logic;
+ step_pos : in std_logic;
+ step_neg : in std_logic;
+ sampling_period : in std_logic_vector(19 downto 0);
+ vel_meas : out std_logic_vector(19 downto 0));
+end simple_enc_vel_detect_6;
+
+architecture RTL of simple_enc_vel_detect_6 is
+
+ signal init_i, sampling_pulse : std_logic;
+
+ signal sampling_per_cnt : std_logic_vector(19 downto 0);
+ signal vel_meas_i : std_logic_vector(19 downto 0);
+ signal vel_meas_sat_pos : std_logic_vector(19 downto 0);
+ signal vel_meas_sat_neg : std_logic_vector(19 downto 0);
+
+begin -- RTL
+
+ pVEL_DETECT : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ init_i <= init;
+ if(init_i = '1' or sampling_pulse = '1') then
+ sampling_per_cnt <= (others => '0');
+ else
+ sampling_per_cnt <= std_logic_vector(unsigned(sampling_per_cnt)+1);
+ end if;
+ if(init_i = '1' or sampling_pulse = '1') then
+ vel_meas_i <= (others => '0');
+ elsif(step_pos = '1' and signed(vel_meas_i) < signed(vel_meas_sat_pos)) then
+ vel_meas_i <= std_logic_vector(signed(vel_meas_i)+1);
+ elsif(step_neg = '1' and signed(vel_meas_i) > signed(vel_meas_sat_neg)) then
+ vel_meas_i <= std_logic_vector(signed(vel_meas_i)-1);
+ end if;
+ if(init_i = '1') then
+ vel_meas <= (others => '0');
+ elsif(sampling_pulse = '1') then
+ vel_meas <= vel_meas_i;
+ end if;
+ end if;
+ end process pVEL_DETECT;
+
+ sampling_pulse <= '1' when unsigned(sampling_per_cnt) = unsigned(sampling_period)-1 else '0';
+
+ -- define positive and negative saturation thresholds
+ vel_meas_sat_pos <= (vel_meas_i'left => '0', others => '1');
+ vel_meas_sat_neg <= (vel_meas_i'left => '1', others => '0');
+
+end RTL;
diff --git a/generic_ip/fire_pulse_manager/7/src/smb_diagnostics_6.vhd b/generic_ip/fire_pulse_manager/7/src/smb_diagnostics_6.vhd
new file mode 100644
index 0000000..2a0efc8
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/smb_diagnostics_6.vhd
@@ -0,0 +1,702 @@
+-------------------------------------------------------------------------------
+-- Title : smb diagnostic block
+-- Project : SMB
+-------------------------------------------------------------------------------
+-- File : smb_diagnostics_6.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2016-08-02
+-- Last update: 2020-04-16
+-- SVN ID : Git
+-- Standard : VHDL'2008
+-------------------------------------------------------------------------------
+-- Description: This block includes all the SMB diagnostic functionalities
+-- except the event logger.
+-------------------------------------------------------------------------------
+-- altera vhdl_input_version vhdl_2008
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity smb_diagnostics_6 is
+ port (
+ clk : in std_logic;
+ reset_n : in std_logic := '1';
+ -- External sync reset (via daisy-chain)
+ ext_diag_rst : in std_logic;
+ -- diagnostic inputs
+ rs422_phase0 : in std_logic;
+ rs422_phase1 : in std_logic;
+ rs422_zero_ph : in std_logic;
+ rs422_prod_det : in std_logic;
+ ttl_phase0 : in std_logic;
+ ttl_phase1 : in std_logic;
+ ttl_zero_ph : in std_logic;
+ ttl_prod_det : in std_logic;
+ ttl_prod_det_npn : in std_logic;
+ filt_phase0 : in std_logic;
+ filt_phase1 : in std_logic;
+ filt_zero_ph : in std_logic;
+ filt_prod_det : in std_logic;
+ enc_out : in std_logic;
+ pd_out : in std_logic;
+ pos_step : in std_logic;
+ neg_step : in std_logic;
+ drop_watch : in std_logic;
+ fire_req : in std_logic;
+ -- local timer
+ fine_time : in std_logic_vector(27 downto 0);
+ coarse_time : in std_logic_vector(31 downto 0);
+ -- Absolute Position
+ abs_position : out std_logic_vector(31 downto 0);
+ -- Interrupt Senders
+ ins_diag_irq_0 : out std_logic;
+ ins_diag_irq_1 : out std_logic;
+ ins_diag_irq_2 : out std_logic;
+ -- Avalon MM Interface
+ avs_address : in std_logic_vector( 5 downto 0);
+ avs_write : in std_logic;
+ avs_writedata : in std_logic_vector(31 downto 0);
+ avs_read : in std_logic;
+ avs_readdatavalid : out std_logic;
+ avs_readdata : out std_logic_vector(31 downto 0));
+end entity smb_diagnostics_6;
+
+architecture rtl of smb_diagnostics_6 is
+
+ constant ADDR_WIDTH : integer := avs_address'length;
+
+ constant DIAG_INIT_REG : std_logic_vector(5 downto 0) := b"000000";
+ constant DIAG_IN_STATUS_REG : std_logic_vector(5 downto 0) := b"000001";
+ constant PHASE0_CNT_REG : std_logic_vector(5 downto 0) := b"000010";
+ constant PHASE1_CNT_REG : std_logic_vector(5 downto 0) := b"000011";
+ constant ZERO_PH_CNT_REG : std_logic_vector(5 downto 0) := b"000100";
+ constant PD_CNT_REG : std_logic_vector(5 downto 0) := b"000101";
+ constant ENC_OUT_CNT_REG : std_logic_vector(5 downto 0) := b"000110";
+ constant PD_OUT_CNT_REG : std_logic_vector(5 downto 0) := b"000111";
+ constant FIRE_REQ_CNT_REG : std_logic_vector(5 downto 0) := b"001000";
+ constant UNUSED_REG_0 : std_logic_vector(5 downto 0) := b"001001";
+ constant UNUSED_REG_1 : std_logic_vector(5 downto 0) := b"001010";
+ constant UNUSED_REG_2 : std_logic_vector(5 downto 0) := b"001011";
+ constant ENC_D_TIME_REG : std_logic_vector(5 downto 0) := b"001100";
+ constant ENC_DMIN_TIME_REG : std_logic_vector(5 downto 0) := b"001101";
+ constant ENC_DMAX_TIME_REG : std_logic_vector(5 downto 0) := b"001110";
+ constant ENC_D_TIME_PREV_REG : std_logic_vector(5 downto 0) := b"001111";
+ constant ENC_D_TIME_MEAS_STEP : std_logic_vector(5 downto 0) := b"010000";
+ constant POSITION_CNT_REG : std_logic_vector(5 downto 0) := b"010001";
+ constant DIR_COUNT_THRES_REG : std_logic_vector(5 downto 0) := b"010010";
+ constant DIR_COUNT_REG : std_logic_vector(5 downto 0) := b"010011";
+ constant ENC_SAMPL_PER_REG : std_logic_vector(5 downto 0) := b"010100";
+ constant ENC_FIFO_CS_REG : std_logic_vector(5 downto 0) := b"010101";
+ constant ENC_FIFO_OUT_REG : std_logic_vector(5 downto 0) := b"010110";
+ constant PD_FIFO_CS_REG : std_logic_vector(5 downto 0) := b"010111";
+ constant PD_FIFO_OUT_REG : std_logic_vector(5 downto 0) := b"011000";
+ constant PD_WATCH_DOG_CTRL : std_logic_vector(5 downto 0) := b"011001";
+ constant PD_WATCH_DOG_THRES : std_logic_vector(5 downto 0) := b"011010";
+ constant IRQ_MNG_REG : std_logic_vector(5 downto 0) := b"011011";
+
+ -- signals
+ type fsm_status_t is (idle, wait_ph1_ris, wait_ph0_ris);
+ signal fsm_status_curr,fsm_status_next : fsm_status_t;
+ --
+ signal filt_phase0_d, filt_phase1_d, filt_zero_ph_d, filt_prod_det_d : std_logic;
+ signal enc_out_d, pd_out_d, filt_phase0_p, filt_phase1_p, init_i : std_logic;
+ signal filt_zero_ph_p, filt_prod_det_p, enc_out_p, pd_out_p : std_logic;
+ signal init, rst_counters_i, rst_counters, rst_measur_i, rst_measur : std_logic;
+ signal rst_dir, rst_dir_i, enable_diff_measur, meas_enc_p : std_logic;
+ signal ph0_rising, ph0_falling, ph1_rising, ph1_falling : std_logic;
+ signal set_dir_forward, set_dir_backward, dir_pos_sat, dir_neg_sat : std_logic;
+ signal direction, direction_d, direction_change : std_logic;
+ signal sampling_time, fifo_rd_en, fifo_wr_en, fifo_full, fifo_error : std_logic;
+ signal rst_fifo_i, rst_fifo, rst_pos, rst_pos_i, avs_read_i : std_logic;
+ signal pd_fifo_error, pd_fifo_wr_en, pd_fifo_rd_en, pd_fifo_full : std_logic;
+ signal pd_p, pd_log_src, pd_fifo_alarm, enc_fifo_alarm : std_logic;
+ signal clr_pd_pos, pd_wd_en, pd_wd_alarm, rst_pd_fifo, rst_pd_fifo_i : std_logic;
+ signal fire_req_d, fire_req_p : std_logic;
+ --
+ signal enable_diff_measur_cnt : std_logic_vector( 1 downto 0);
+ signal irq_en, irq_clr, irq_src, irq_src_d : std_logic_vector( 2 downto 0);
+ signal irq, irq_val, irq_mask, pd_data_sel : std_logic_vector( 2 downto 0);
+ signal meas_enc_pulse : std_logic_vector( 3 downto 0);
+ signal pd_fifo_usedw, pd_fifo_thres : std_logic_vector( 7 downto 0);
+ signal fifo_thres, fifo_usedw : std_logic_vector( 9 downto 0);
+ signal dir_cnt, dir_change_cnt : std_logic_vector(15 downto 0);
+ signal pos_dir_thres, neg_dir_thres : std_logic_vector(15 downto 0);
+ signal meas_pulse_cnt, meas_step : std_logic_vector(15 downto 0);
+ signal input_status : std_logic_vector(16 downto 0);
+ signal sampling_period, sampling_time_cnt : std_logic_vector(27 downto 0);
+ signal fine_time_l : std_logic_vector(27 downto 0);
+ signal filt_phase0_cnt, filt_phase1_cnt : std_logic_vector(31 downto 0);
+ signal filt_zero_ph_cnt, filt_prod_det_cnt : std_logic_vector(31 downto 0);
+ signal enc_out_cnt, pd_out_cnt : std_logic_vector(31 downto 0);
+ signal enc_delta_time, enc_delta_time_prev : std_logic_vector(31 downto 0);
+ signal enc_delta_time_cnt : std_logic_vector(31 downto 0);
+ signal enc_delta_time_min, enc_delta_time_max : std_logic_vector(31 downto 0);
+ signal fifo_d, fifo_q, pos_cnt : std_logic_vector(31 downto 0);
+ signal pd_fifo_d, pd_fifo_q : std_logic_vector(31 downto 0);
+ signal pd_pos, coarse_time_l, pd_wd_thres : std_logic_vector(31 downto 0);
+ signal pd_delta_pos, pd_delta_pos_abs : std_logic_vector(31 downto 0);
+ signal fire_req_cnt : std_logic_vector(31 downto 0);
+
+
+begin
+
+ pInit : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ init <= init_i or ext_diag_rst;
+ end if;
+ end process pInit;
+
+ -----------------------------------------------------------------------------
+ -- Input Status
+ -----------------------------------------------------------------------------
+
+ pInputStatus : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ input_status( 0) <= rs422_phase0;
+ input_status( 1) <= rs422_phase1;
+ input_status( 2) <= rs422_zero_ph;
+ input_status( 3) <= rs422_prod_det;
+ input_status( 4) <= ttl_phase0;
+ input_status( 5) <= ttl_phase1;
+ input_status( 6) <= ttl_zero_ph;
+ input_status( 7) <= ttl_prod_det;
+ input_status( 8) <= ttl_prod_det_npn;
+ input_status( 9) <= filt_phase0;
+ input_status(10) <= filt_phase1;
+ input_status(11) <= filt_zero_ph;
+ input_status(12) <= filt_prod_det;
+ input_status(13) <= enc_out;
+ input_status(14) <= pd_out;
+ input_status(15) <= drop_watch;
+ input_status(16) <= fire_req;
+ end if;
+ end process pInputStatus;
+
+ -----------------------------------------------------------------------------
+ -- Edge detection and counting
+ -----------------------------------------------------------------------------
+
+ pEdgeDetect_Cnt : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ filt_phase0_d <= filt_phase0;
+ filt_phase1_d <= filt_phase1;
+ filt_zero_ph_d <= filt_zero_ph;
+ filt_prod_det_d <= filt_prod_det;
+ enc_out_d <= enc_out;
+ pd_out_d <= pd_out;
+ fire_req_d <= fire_req;
+ if(rst_counters = '1') then
+ filt_phase0_cnt <= (others => '0');
+ elsif(filt_phase0_p = '1') then
+ filt_phase0_cnt <= std_logic_vector(unsigned(filt_phase0_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ filt_phase1_cnt <= (others => '0');
+ elsif(filt_phase1_p = '1') then
+ filt_phase1_cnt <= std_logic_vector(unsigned(filt_phase1_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ filt_zero_ph_cnt <= (others => '0');
+ elsif(filt_zero_ph_p = '1') then
+ filt_zero_ph_cnt <= std_logic_vector(unsigned(filt_zero_ph_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ filt_prod_det_cnt <= (others => '0');
+ elsif(filt_prod_det_p = '1') then
+ filt_prod_det_cnt <= std_logic_vector(unsigned(filt_prod_det_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ enc_out_cnt <= (others => '0');
+ elsif(enc_out_p = '1') then
+ enc_out_cnt <= std_logic_vector(unsigned(enc_out_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ pd_out_cnt <= (others => '0');
+ elsif(pd_out_p = '1') then
+ pd_out_cnt <= std_logic_vector(unsigned(pd_out_cnt)+1);
+ end if;
+ if(rst_counters = '1') then
+ fire_req_cnt <= (others => '0');
+ elsif(fire_req_p = '1') then
+ fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1);
+ end if;
+ end if;
+ end process pEdgeDetect_Cnt;
+
+ filt_phase0_p <= filt_phase0 and not filt_phase0_d;
+ filt_phase1_p <= filt_phase1 and not filt_phase1_d;
+ filt_zero_ph_p <= filt_zero_ph and not filt_zero_ph_d;
+ filt_prod_det_p <= filt_prod_det and not filt_prod_det_d;
+ enc_out_p <= enc_out and not enc_out_d;
+ pd_out_p <= pd_out and not pd_out_d;
+ fire_req_p <= fire_req and not fire_req_d;
+
+ rst_counters <= rst_counters_i or init;
+
+ -----------------------------------------------------------------------------
+ -- Speed and acceleration measurements
+ -----------------------------------------------------------------------------
+
+ pMeasure : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(rst_measur = '1' or meas_enc_p = '1') then
+ meas_pulse_cnt <= (others => '0');
+ elsif(enc_out_d = '1') then
+ meas_pulse_cnt <= std_logic_vector(unsigned(meas_pulse_cnt)+1);
+ end if;
+ if(rst_measur = '1') then
+ meas_enc_pulse <= (others => '0');
+ else
+ meas_enc_pulse <= meas_enc_pulse(meas_enc_pulse'high-1 downto 0) & meas_enc_p;
+ end if;
+ if(rst_measur = '1' or meas_enc_pulse(0) = '1') then
+ enc_delta_time_cnt <= (others => '0');
+ else
+ enc_delta_time_cnt <= std_logic_vector(unsigned(enc_delta_time_cnt)+1);
+ end if;
+ if(rst_measur = '1') then
+ enc_delta_time <= (others => '0');
+ enc_delta_time_prev <= (others => '0');
+ elsif(meas_enc_pulse(0) = '1') then
+ enc_delta_time <= enc_delta_time_cnt;
+ enc_delta_time_prev <= enc_delta_time;
+ end if;
+ if(rst_measur = '1' or rst_counters = '1') then
+ enable_diff_measur_cnt <= (others => '0');
+ elsif(meas_enc_p = '1') then
+ enable_diff_measur_cnt <= std_logic_vector(unsigned(enable_diff_measur_cnt)+1);
+ end if;
+ if(rst_measur = '1' or rst_counters = '1') then
+ enable_diff_measur <= '0';
+ elsif(enable_diff_measur_cnt = "11") then
+ enable_diff_measur <= '1';
+ end if;
+ if(enable_diff_measur = '0') then
+ enc_delta_time_min <= (others => '1');
+ elsif(meas_enc_pulse(2) = '1' and unsigned(enc_delta_time) < unsigned(enc_delta_time_min)) then
+ enc_delta_time_min <= enc_delta_time;
+ end if;
+ if(enable_diff_measur = '0') then
+ enc_delta_time_max <= (others => '0');
+ elsif(meas_enc_pulse(2) = '1' and unsigned(enc_delta_time) > unsigned(enc_delta_time_max)) then
+ enc_delta_time_max <= enc_delta_time;
+ end if;
+ end if;
+ end process pMeasure;
+
+ meas_enc_p <= '1' when enc_out_p = '1' and unsigned(meas_pulse_cnt) = unsigned(meas_step) else '0';
+
+ rst_measur <= rst_measur_i or init;
+
+ -----------------------------------------------------------------------------
+ -- Direction detection & Position Tracking
+ -----------------------------------------------------------------------------
+
+ -- Direction is detected by checking the order of rising and falling edged
+ -- between phase-0 and phase-1.
+ -- Forward direction => Phase-0 is anticipated w.r.t. Phase-1
+ -- Backward direction => Phase-0 is delayed w.r.t. Phase-1
+
+ ph0_rising <= filt_phase0_p;
+ ph0_falling <= not filt_phase0 and filt_phase0_d;
+ ph1_rising <= filt_phase1_p;
+ ph1_falling <= not filt_phase1 and filt_phase1_d;
+
+ rst_dir <= rst_dir_i or init;
+
+ -- Use a FSM to detect the sequence of events:
+ -- FSM Status Register
+ pFSM_SR : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(rst_dir = '1') then
+ fsm_status_curr <= idle;
+ else
+ fsm_status_curr <= fsm_status_next;
+ end if;
+ end if;
+ end process pFSM_SR;
+
+ -- FSM Combinational Logic
+ pFSM_CL : process(fsm_status_curr, ph0_rising, ph0_falling, ph1_rising, ph1_falling)
+ begin
+ -- default assignments
+ set_dir_forward <= '0';
+ set_dir_backward <= '0';
+ --
+ fsm_status_next <= fsm_status_curr;
+
+ case fsm_status_curr is
+ when idle =>
+ if(ph0_rising = '1') then
+ fsm_status_next <= wait_ph1_ris;
+ elsif(ph1_rising = '1') then
+ fsm_status_next <= wait_ph0_ris;
+ end if;
+
+ when wait_ph1_ris =>
+ if(ph1_rising = '1') then
+ set_dir_forward <= '1';
+ fsm_status_next <= idle;
+ elsif(ph0_falling = '1') then
+ fsm_status_next <= idle;
+ end if;
+
+ when wait_ph0_ris =>
+ if(ph0_rising = '1') then
+ set_dir_backward <= '1';
+ fsm_status_next <= idle;
+ elsif(ph1_falling = '1') then
+ fsm_status_next <= idle;
+ end if;
+
+ when others => null;
+ end case;
+ end process pFSM_CL;
+
+ pDirRegs : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(rst_dir = '1') then
+ dir_cnt <= (others => '0');
+ elsif(set_dir_forward = '1' and dir_pos_sat = '0') then
+ dir_cnt <= std_logic_vector(signed(dir_cnt)+1);
+ elsif(set_dir_backward = '1' and dir_neg_sat = '0') then
+ dir_cnt <= std_logic_vector(signed(dir_cnt)-1);
+ end if;
+ direction_d <= direction;
+ if(rst_dir = '1') then
+ dir_change_cnt <= (others => '0');
+ elsif(direction_change = '1') then
+ dir_change_cnt <= std_logic_vector(unsigned(dir_change_cnt)+1);
+ end if;
+ end if;
+ end process pDirRegs;
+
+ direction <= dir_cnt(dir_cnt'high);
+ direction_change <= direction xor direction_d;
+
+ -- Positive/Negative saturation for the direction counter
+ dir_pos_sat <= '1' when signed(dir_cnt) > signed(pos_dir_thres) else '0';
+ dir_neg_sat <= '1' when signed(dir_cnt) < signed(neg_dir_thres) else '0';
+
+ -- Position Tracking
+ pPOS_TRACK : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(rst_pos = '1') then
+ pos_cnt <= (others => '0');
+ elsif(pos_step = '1') then
+ pos_cnt <= std_logic_vector(signed(pos_cnt)+1);
+ elsif(neg_step = '1') then
+ pos_cnt <= std_logic_vector(signed(pos_cnt)-1);
+ end if;
+ abs_position <= pos_cnt;
+ end if;
+ end process pPOS_TRACK;
+
+ rst_pos <= init or rst_pos_i;
+
+ -----------------------------------------------------------------------------
+ -- PD logging
+ -----------------------------------------------------------------------------
+
+ pPD_log : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(init = '1') then
+ pd_fifo_error <= '0';
+ elsif(pd_fifo_wr_en = '1' and pd_fifo_full = '1') then
+ pd_fifo_error <= '1';
+ end if;
+ if(init = '0' and pd_p = '1') then
+ pd_data_sel <= "001";
+ else
+ pd_data_sel <= pd_data_sel(1 downto 0) & '0';
+ end if;
+ if(init = '1') then
+ fine_time_l <= (others => '0');
+ coarse_time_l <= (others => '0');
+ pd_pos <= (others => '0');
+ elsif(pd_p = '1') then
+ fine_time_l <= fine_time;
+ coarse_time_l <= coarse_time;
+ pd_pos <= pos_cnt;
+ end if;
+ end if;
+ end process pPD_log;
+
+ pd_p <= pd_out_p when pd_log_src = '1' else filt_prod_det_p;
+
+ iPD_log_fifo : entity work.sync_fifo
+ generic map(
+ FIFO_WIDTH => 32,
+ FIFO_DEPTH => 256)
+ port map (
+ clock => clk,
+ data => pd_fifo_d,
+ rdreq => pd_fifo_rd_en,
+ sclr => rst_pd_fifo,
+ wrreq => pd_fifo_wr_en,
+ empty => open,
+ full => pd_fifo_full,
+ q => pd_fifo_q,
+ usedw => pd_fifo_usedw);
+
+ pd_fifo_rd_en <= '1' when avs_read = '1' and avs_address = PD_FIFO_OUT_REG else '0';
+
+ pd_fifo_alarm <= '1' when unsigned(pd_fifo_usedw) >= unsigned(pd_fifo_thres) else '0';
+
+ -- FIFO write logic
+ pd_fifo_wr_en <= pd_data_sel(2) or pd_data_sel(1) or pd_data_sel(0);
+
+ -- select the input for the pd fifo
+ with pd_data_sel select
+ pd_fifo_d <=
+ X"0" & fine_time_l when "001",
+ coarse_time_l when "010",
+ pd_pos when others;
+
+ rst_pd_fifo <= rst_pd_fifo_i or init;
+
+ -- PD Positional Watch-Dog
+ pPD_WatchDog : process(clk)
+ begin
+ if(clk = '1') then
+ if(init = '1' or clr_pd_pos = '1' or filt_prod_det_p = '1') then
+ pd_delta_pos <= (others => '0');
+ elsif(pos_step = '1') then
+ pd_delta_pos <= std_logic_vector(signed(pd_delta_pos)+1);
+ elsif(neg_step = '1') then
+ pd_delta_pos <= std_logic_vector(signed(pd_delta_pos)-1);
+ end if;
+ -- compare the absolute value of the delta position against the
+ -- threshold. Use the 1's complement to save some logic.
+ if(pd_wd_en = '1' and unsigned(pd_delta_pos_abs) > unsigned(pd_wd_thres)) then
+ pd_wd_alarm <= '1';
+ else
+ pd_wd_alarm <= '0';
+ end if;
+ end if;
+ end process pPD_WatchDog;
+
+ pd_delta_pos_abs <= '0' & pd_delta_pos(30 downto 0) when pd_delta_pos(31) = '0' else '0' & not pd_delta_pos(30 downto 0);
+
+ -----------------------------------------------------------------------------
+ -- Encoder pulse count buffering (ACTUALLY NOW IS POSITION COUNT SAMPLING!!!)
+ -----------------------------------------------------------------------------
+
+ -- The encoder pulse count is periodically sampled. The samples are stored in
+ -- a dedicated FIFO and they can be used to generate a speed/acceleration
+ -- profile. => CHANGED: JUST using the position count, because it is more
+ -- it is independent of the encoder directionality settings
+
+ pEncPulseSample : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ if(rst_fifo = '1' or sampling_time = '1') then
+ sampling_time_cnt <= (others => '0');
+ else
+ sampling_time_cnt <= std_logic_vector(unsigned(sampling_time_cnt)+1);
+ end if;
+ if(rst_fifo = '1') then
+ fifo_error <= '0';
+ elsif(fifo_wr_en = '1' and fifo_full = '1') then
+ fifo_error <= '1';
+ end if;
+ fifo_wr_en <= sampling_time;
+ --fifo_d <= enc_out_cnt;
+ fifo_d <= pos_cnt;
+ end if;
+ end process pEncPulseSample;
+
+ sampling_time <= '1' when unsigned(sampling_time_cnt) = unsigned(sampling_period) else '0';
+
+ iEncPulseFifo : entity work.sync_fifo
+ generic map(
+ FIFO_WIDTH => 32,
+ FIFO_DEPTH => 1024)
+ port map (
+ clock => clk,
+ data => fifo_d,
+ rdreq => fifo_rd_en,
+ sclr => rst_fifo,
+ wrreq => fifo_wr_en,
+ empty => open,
+ full => fifo_full,
+ q => fifo_q,
+ usedw => fifo_usedw);
+
+ fifo_rd_en <= '1' when avs_read = '1' and avs_address = ENC_FIFO_OUT_REG else '0';
+
+ enc_fifo_alarm <= '1' when unsigned(fifo_usedw) >= unsigned(fifo_thres) else '0';
+
+ rst_fifo <= init or rst_fifo_i or rst_counters_i;
+
+ -----------------------------------------------------------------------------
+ -- IRQ generation and management
+ -----------------------------------------------------------------------------
+
+ pIRQ : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ ins_diag_irq_0 <= '0';
+ ins_diag_irq_1 <= '0';
+ ins_diag_irq_2 <= '0';
+ irq <= "000";
+ irq_src_d <= "000";
+ elsif(clk = '1' and clk'event) then
+ irq_src_d <= irq_src;
+ for n in 0 to 2 loop
+ if(irq_clr(n) = '1') then
+ irq(n) <= '0';
+ elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then
+ irq(n) <= '1';
+ end if;
+ end loop; -- n
+ ins_diag_irq_0 <= irq_val(0);
+ ins_diag_irq_1 <= irq_val(1);
+ ins_diag_irq_2 <= irq_val(2);
+ end if;
+ end process pIRQ;
+
+ irq_val <= irq and not irq_mask;
+ irq_src <= pd_wd_alarm & pd_fifo_alarm & enc_fifo_alarm;
+
+ -----------------------------------------------------------------------------
+ -- C&S registers (Avalon-MM I/F)
+ -----------------------------------------------------------------------------
+
+ pCTRL_STATUS : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ avs_read_i <= '0';
+ avs_readdatavalid <= '0';
+ avs_readdata <= (others => '0');
+ --
+ init_i <= '0';
+ rst_counters_i <= '0';
+ rst_measur_i <= '0';
+ rst_dir_i <= '0';
+ rst_fifo_i <= '0';
+ rst_pos_i <= '0';
+ rst_pd_fifo_i <= '0';
+ pd_log_src <= '0';
+ pd_wd_en <= '0';
+ clr_pd_pos <= '0';
+ irq_en <= "000";
+ irq_clr <= "000";
+ irq_mask <= "000";
+ meas_step <= (0 => '1', others => '0');
+ sampling_period <= (others => '0');
+ pos_dir_thres <= X"007F"; -- +127
+ neg_dir_thres <= X"FF81"; -- -127
+ elsif(clk = '1' and clk'event) then
+ -- CTRL registers
+ if(avs_write = '1') then
+ case avs_address is
+ when DIAG_INIT_REG =>
+ init_i <= avs_writedata( 0);
+ rst_counters_i <= avs_writedata( 1);
+ rst_measur_i <= avs_writedata( 2);
+ rst_dir_i <= avs_writedata( 3);
+ rst_fifo_i <= avs_writedata( 4);
+ rst_pos_i <= avs_writedata( 5);
+ rst_pd_fifo_i <= avs_writedata( 6);
+ when ENC_D_TIME_MEAS_STEP =>
+ meas_step <= avs_writedata(meas_step'range);
+ when DIR_COUNT_THRES_REG =>
+ pos_dir_thres <= avs_writedata(15 downto 0);
+ neg_dir_thres <= avs_writedata(31 downto 16);
+ when ENC_SAMPL_PER_REG =>
+ sampling_period <= avs_writedata(sampling_period'range);
+ when ENC_FIFO_CS_REG =>
+ fifo_thres <= avs_writedata(fifo_thres'range);
+ when PD_FIFO_CS_REG =>
+ pd_fifo_thres <= avs_writedata(pd_fifo_thres'range);
+ pd_log_src <= avs_writedata(15);
+ when PD_WATCH_DOG_CTRL =>
+ pd_wd_en <= avs_writedata( 0);
+ clr_pd_pos <= avs_writedata( 1);
+ when PD_WATCH_DOG_THRES =>
+ pd_wd_thres <= avs_writedata;
+ when IRQ_MNG_REG =>
+ irq_en <= avs_writedata( 2 downto 0);
+ irq_clr <= avs_writedata( 6 downto 4);
+ irq_mask <= avs_writedata(10 downto 8);
+ when others => null;
+ end case;
+ end if;
+
+ -- Read Ctrl & Status registers
+ avs_read_i <= avs_read;
+ -- Read valid is delayed of an additional clock cycle to take into
+ -- account for the FIFO latency
+ avs_readdatavalid <= avs_read_i;
+ if(avs_read_i = '1') then
+ case avs_address is
+ when DIAG_INIT_REG =>
+ avs_readdata <= X"000000" & b"0" & rst_pd_fifo_i & rst_pos_i & rst_fifo_i & rst_dir_i & rst_measur_i & rst_counters_i & init_i;
+ when DIAG_IN_STATUS_REG =>
+ avs_readdata(input_status'range) <= input_status;
+ avs_readdata(31 downto input_status'length) <= (others => '0');
+ when PHASE0_CNT_REG =>
+ avs_readdata <= filt_phase0_cnt;
+ when PHASE1_CNT_REG =>
+ avs_readdata <= filt_phase1_cnt;
+ when ZERO_PH_CNT_REG =>
+ avs_readdata <= filt_zero_ph_cnt;
+ when PD_CNT_REG =>
+ avs_readdata <= filt_prod_det_cnt;
+ when ENC_OUT_CNT_REG =>
+ avs_readdata <= enc_out_cnt;
+ when PD_OUT_CNT_REG =>
+ avs_readdata <= pd_out_cnt;
+ when FIRE_REQ_CNT_REG =>
+ avs_readdata <= fire_req_cnt;
+ when ENC_D_TIME_REG =>
+ avs_readdata <= enc_delta_time;
+ when ENC_DMIN_TIME_REG =>
+ avs_readdata <= enc_delta_time_min;
+ when ENC_DMAX_TIME_REG =>
+ avs_readdata <= enc_delta_time_max;
+ when ENC_D_TIME_PREV_REG =>
+ avs_readdata <= enc_delta_time_prev;
+ when ENC_D_TIME_MEAS_STEP =>
+ avs_readdata <= X"0000" & meas_step;
+ when POSITION_CNT_REG =>
+ avs_readdata <= pos_cnt;
+ when DIR_COUNT_THRES_REG =>
+ avs_readdata <= neg_dir_thres & pos_dir_thres;
+ when DIR_COUNT_REG =>
+ avs_readdata <= dir_change_cnt & dir_cnt;
+ when ENC_SAMPL_PER_REG =>
+ avs_readdata <= X"0" & sampling_period;
+ when ENC_FIFO_CS_REG =>
+ avs_readdata <= fifo_error & b"00000" & fifo_usedw & b"000000" & fifo_thres;
+ when ENC_FIFO_OUT_REG =>
+ avs_readdata <= fifo_q;
+ when PD_FIFO_CS_REG =>
+ avs_readdata <= pd_fifo_error & b"0000000" & pd_fifo_usedw & pd_log_src & b"0000000" & pd_fifo_thres;
+ when PD_FIFO_OUT_REG =>
+ avs_readdata <= pd_fifo_q;
+ when PD_WATCH_DOG_CTRL =>
+ avs_readdata <= (0 => pd_wd_en, 1 => clr_pd_pos, 4 => pd_wd_alarm, others => '0');
+ when PD_WATCH_DOG_THRES =>
+ avs_readdata <= pd_wd_thres;
+ when IRQ_MNG_REG =>
+ avs_readdata <= X"0000" & '0' & irq_val & '0' & irq_mask & '0' & irq_clr & '0' & irq_en;
+ when others =>
+ avs_readdata <= X"BAD1BAD0";
+ end case;
+ end if;
+ end if;
+ end process pCTRL_STATUS;
+
+end architecture rtl;
diff --git a/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb.vhd b/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb.vhd
new file mode 100644
index 0000000..7a4a0d0
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb.vhd
@@ -0,0 +1,768 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_manager_tb
+-- Project : fire_pulse_manager
+-------------------------------------------------------------------------------
+-- File : fire_pulse_manager_tb.vhd
+-- Author : Christos Spirotis
+-- Company : Global Inkjet Systems
+-- Created : 2018-08-10
+-- Last update: 2020-04-20
+-- SVN ID : Git
+-- Standard : VHDL'08
+-------------------------------------------------------------------------------
+-- Description:
+-- Testbench for fire pulse manager block
+-------------------------------------------------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+use ieee.math_real.all;
+
+use std.textio.all;
+
+library work;
+use work.fire_pulse_7_pkg.all;
+use work.fpm_ctrl_7_pkg.all;
+use work.log_pkg.all;
+use work.avalon_verify_pkg_2.all;
+use work.pulse_generator_3_pkg.all;
+use work.enc_pd_emul_1_pkg.all;
+use work.fire_pulse_manager_7_tb_pkg.all;
+
+library osvvm;
+use osvvm.RandomPkg.all;
+
+entity fire_pulse_manager_7_tb is
+end fire_pulse_manager_7_tb;
+
+architecture behav of fire_pulse_manager_7_tb is
+
+ constant DEV_NUM : integer := 2;
+
+ constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the
+ -- UART-Rx on the POF
+
+ constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output
+
+ constant ENC_PPR : natural := 10000;
+ constant ENC_FREQ : enc_freq_t := 1.0e6;
+
+ constant PD_PULSE_W : pd_pulse_width_t := 0.5;
+ constant PD_PERIOD : pd_period_t := 2.0;
+
+ constant NUM_ITERATIONS : natural := 5;
+ constant SWATHE_LEN : integer := 2000;
+ constant IMAGE_SIZE : integer := 100;
+ constant DIV_RATIO : real := 5.0;
+ constant SUBPIX_PHASES : integer := 5;
+ constant SEL_SUBPIX_PH : integer := 4;
+ constant START_DIR : enc_dir_t := DIR_0;
+
+
+ -- when DRIVE_DROP_WATCH is true, FPM output pof_tx is driven with the
+ -- drop-watch signal
+ constant DRIVE_DROP_WATCH : boolean := true;
+
+ constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
+
+ type ch_offset_t is array (0 to CH_NUM - 1) of integer;
+ signal ch_offset : ch_offset_t := (others => 0);
+
+ type fire_pulse_t is array (0 to CH_NUM-1) of std_logic_vector(31 downto 0);
+ signal ch_fire_pulse : fire_pulse_t;
+ signal ch_start_of_image : fire_pulse_t;
+
+ type avs_read_bus_t is array (0 to DEV_NUM - 1) of std_logic_vector(31 downto 0);
+
+ signal reset_n : std_logic := '0';
+ signal clk : std_logic := '0';
+ signal rx_clk : std_logic := '0';
+ signal pof_tx, pof_rx : std_logic;
+ signal fire_pulse : std_logic_vector(32*CH_NUM-1 downto 0);
+ signal start_of_image : std_logic_vector(32*CH_NUM-1 downto 0);
+ signal avs_address : std_logic_vector(14 downto 0);
+ signal avs_write : std_logic_vector(DEV_NUM - 1 downto 0);
+ signal avs_writedata : std_logic_vector(31 downto 0);
+ signal avs_read : std_logic_vector(DEV_NUM - 1 downto 0);
+ signal avs_waitrequest : std_logic_vector(DEV_NUM - 1 downto 0);
+ signal avs_readdata : avs_read_bus_t;
+ --
+ signal init_tx : std_logic;
+ signal inc_pos : std_logic;
+ signal dec_pos : std_logic;
+ signal abs_position : std_logic_vector(31 downto 0);
+ signal tx_data : std_logic;
+ signal pof_tx_avs_rv : std_logic;
+ signal pof_tx_avs_we_d : std_logic;
+ signal enc_p1 : std_logic;
+ signal enc_p2 : std_logic;
+ signal pd : std_logic;
+ signal seb_epd_enc_p1 : std_logic;
+ signal seb_epd_enc_p2 : std_logic;
+ signal seb_epd_pd : std_logic;
+ --
+ signal emul_address : std_logic_vector( 9 downto 0);
+ signal emul_write : std_logic;
+ signal emul_writedata : std_logic_vector(31 downto 0);
+ signal emul_read : std_logic;
+ signal emul_readdatavalid : std_logic;
+ signal emul_readdata : std_logic_vector(31 downto 0);
+ signal emul_inc_pos : std_logic;
+ signal emul_dec_pos : std_logic;
+ signal emul_pos : std_logic_vector(39 downto 0);
+ --
+ signal enc_dir : enc_dir_t;
+ signal swathe_cnt : integer;
+ signal half_swathe_cnt : integer;
+ signal swathe_pos : integer;
+ signal end_of_swathe : std_logic;
+ signal test_completed : boolean;
+ signal running : boolean;
+ signal configuring : boolean;
+ signal passed : boolean;
+ signal failed : boolean;
+ signal stimuli_completed : boolean;
+ --
+ shared variable error_flag : boolean;
+
+ signal registers_read : boolean := false;
+ signal reprogram_offset : boolean := false;
+ --
+ signal avs_m : mm_m_rec_t;
+ signal avs_s : mm_s_rec_t;
+ signal sel_slave_0 : std_logic;
+ signal sel_slave_1 : std_logic;
+ signal emul_s : mm_s_rec_t;
+ signal emul_m : mm_m_rec_t;
+ --
+ type pd_cnt_t is array (0 to CH_NUM - 1) of integer;
+ signal pd_cnt : pd_cnt_t;
+ type fp_cnt_t is array (0 to CH_NUM - 1) of integer;
+ signal fp_cnt : fp_cnt_t;
+ signal loc_fp_cnt : fp_cnt_t;
+ signal rst_fp_cnt : std_logic;
+ signal ch_pulse_out : std_logic_vector(CH_NUM-1 downto 0);
+ signal ch_pulse_out_d : std_logic_vector(CH_NUM-1 downto 0);
+ signal ch_start_of_img : std_logic_vector(CH_NUM-1 downto 0);
+ --
+ signal run_dw : std_logic;
+ signal dw : std_logic;
+ signal dw_d : std_logic;
+ signal dw_cnt : natural;
+ --
+ signal input_mode : fpm_input_type_t;
+ --
+ signal ext_pulse : std_logic;
+ signal ext_pulse_enable : std_logic;
+
+
+begin -- behav
+
+ clk_pr : process
+ begin
+ clk <= '0';
+ wait for 0.5 * CLK_PERIOD;
+ clk <= '1';
+ wait for 0.5 * CLK_PERIOD;
+ end process clk_pr;
+
+ rx_clk_pr : process
+ begin
+ rx_clk <= '0';
+ wait for 0.5 * RX_CLK_PERIOD;
+ rx_clk <= '1';
+ wait for 0.5 * RX_CLK_PERIOD;
+ end process rx_clk_pr;
+
+ -----------------------------------------------------------------------------
+ -- DUTs : Fire Pulse Manager
+ -----------------------------------------------------------------------------
+
+ iDUT : entity work.fire_pulse_manager_7
+ generic map(
+ SEB_EPD_MODE => true,
+ CH_NUM => CH_NUM)
+ port map(
+ reset_n => reset_n,
+ clk => clk,
+ rx_clk => rx_clk,
+ pof_rx => pof_rx,
+ pof_tx => pof_tx,
+ seb_epd_enc_p1 => seb_epd_enc_p1,
+ seb_epd_enc_p2 => seb_epd_enc_p2,
+ seb_epd_pd => seb_epd_pd,
+ fire_pulse => fire_pulse,
+ start_of_image => start_of_image,
+ mon_pt => open,
+ ins_fpm_irq_0 => open,
+ ins_fpm_irq_1 => open,
+ ins_fpm_irq_2 => open,
+ ins_fpm_irq_3 => open,
+ avs_address => avs_address,
+ avs_write => avs_write(0),
+ avs_writedata => avs_writedata,
+ avs_read => avs_read(0),
+ avs_waitrequest => avs_waitrequest(0),
+ avs_readdata => avs_readdata(0));
+
+ pof_rx <= transport tx_data after POF_DELAY when ext_pulse_enable = '0' else ext_pulse;
+
+ -----------------------------------------------------------------------------
+ -- Split subpixel phases
+ -----------------------------------------------------------------------------
+
+ pSPLIT_SUBPIX_PH : process(all)
+ begin
+ for i in 0 to CH_NUM-1 loop
+ ch_fire_pulse(i) <= fire_pulse(32*i+31 downto 32*i);
+ ch_start_of_image(i) <= start_of_image(32*i+31 downto 32*i);
+ ch_pulse_out(i) <= ch_fire_pulse(i)(0);
+ ch_start_of_img(i) <= ch_start_of_image(i)(SEL_SUBPIX_PH-1);
+ end loop; -- i
+ end process pSPLIT_SUBPIX_PH;
+
+ -----------------------------------------------------------------------------
+ -- Encoder/PD emulator (Stimuli Generator)
+ -----------------------------------------------------------------------------
+
+ -- The Emulator provides the Encoder and PD stimuli to the FPM:
+ -- When using the SEB-POF, the encoder stimuli is given by the absolute position.
+ -- A POF-Transmitter block (below) encodes the Absolute position and PD
+ -- events according to the POF-Protocol format.
+ -- When using the SEB-EPD, the encoder phase-1/2 outputs of the emulator are
+ -- directly fed as inputs to the FPM
+
+ iEMUL : entity work.enc_pd_emul_1
+ port map (
+ clk => clk,
+ reset_n => reset_n,
+ ttl_pd => open,
+ ttl_enc_p1 => open,
+ ttl_enc_p2 => open,
+ ttl_enc_zp => open,
+ rs422_pd => pd,
+ rs422_enc_p1 => enc_p1,
+ rs422_enc_p2 => enc_p2,
+ rs422_enc_zp => open,
+ abs_pos_out => emul_pos,
+ set_pos_out => open,
+ inc_pos_out => inc_pos,
+ dec_pos_out => dec_pos,
+ avs_address => emul_address,
+ avs_write => emul_write,
+ avs_writedata => emul_writedata,
+ avs_read => emul_read,
+ avs_readdatavalid => emul_readdatavalid,
+ avs_readdata => emul_readdata);
+
+ abs_position <= emul_pos(31 downto 0);
+
+ seb_epd_pd <= pd;
+ seb_epd_enc_p1 <= enc_p1;
+ seb_epd_enc_p2 <= enc_p2;
+
+ -----------------------------------------------------------------------------
+ -- POF Tx (Stimuli Generator)
+ -----------------------------------------------------------------------------
+
+ iPOF_TX : entity work.pof_tx_0
+ port map(
+ reset_n => reset_n,
+ clk => clk,
+ init => init_tx,
+ pd_in => pd,
+ inc_pos => inc_pos,
+ dec_pos => dec_pos,
+ abs_position => abs_position,
+ tx_data => tx_data,
+ avs_address => avs_address(2 downto 0),
+ avs_write => avs_write(1),
+ avs_writedata => avs_writedata,
+ avs_read => avs_read(1),
+ avs_readdatavalid => pof_tx_avs_rv,
+ avs_readdata => avs_readdata(1));
+
+ -- Generate a dummy waitrequest for the POF-tx
+ pPOF_TX_DUMMY_WR : process(clk)
+ begin
+ if(clk = '1' and clk'event) then
+ pof_tx_avs_we_d <= avs_write(1);
+ end if;
+ end process pPOF_TX_DUMMY_WR;
+
+ avs_waitrequest(1) <= '0' when pof_tx_avs_we_d = '1' or pof_tx_avs_rv = '1' else '0';
+
+ -----------------------------------------------------------------------------
+ -- Stimuli Generation
+ -----------------------------------------------------------------------------
+
+ pSTIMULI : process
+ variable end_of_stimuli : boolean;
+ variable swathe_completed : boolean;
+ variable pd_pos : integer;
+ variable rv : RandomPType;
+
+ begin
+
+ -- initialization
+ init_tx <= '0';
+ enc_dir <= START_DIR;
+ swathe_pos <= 0;
+ --
+ swathe_cnt <= 0;
+ half_swathe_cnt <= 0;
+ stimuli_completed <= false;
+ end_of_swathe <= '0';
+ --
+ mm_m_init(emul_m, use_readvalid => true);
+
+ -- generating the stimulus
+ if(running /= true) then
+ wait until running = true;
+ end if;
+ wait for 200 ns;
+
+ -- Set the initial absolute-position for the encoder emulator
+ set_enc_abs_pos(40x"0", emul_s, emul_m);
+
+ -- Send a Init/Sync pulse to the POF-Tx
+ wait until clk = '1' and clk'event;
+ init_tx <= '1';
+ wait until clk = '1' and clk'event;
+ init_tx <= '0';
+ wait for 500 ns;
+
+ --
+ -- generate the forward swathe
+ end_of_stimuli := false;
+ while end_of_stimuli = false loop
+ --swathe_pos <= 0;
+
+ for i in 0 to CH_NUM - 1 loop
+ ch_offset(i) <= rv.RandInt(0, 199);
+ --ch_offset(i) <= 50;
+ end loop;
+ reprogram_offset <= true;
+ wait until configuring = true;
+ reprogram_offset <= false;
+ wait until configuring = false;
+
+ wait until clk = '1' and clk'event;
+
+ -- start running the encoder
+ run_enc_pulses(ENC_FREQ, enc_dir, true, SWATHE_LEN, ENC_PPR, emul_s, emul_m);
+ if(enc_dir = DIR_0) then
+ log("Running Swathe " & to_string(swathe_cnt + 1) & ", DIR-0.", VMEDIUM);
+ else
+ log("Running Swathe " & to_string(swathe_cnt + 1) & ", DIR-1.", VMEDIUM);
+ end if;
+
+ -- issue a PD to start firing
+ pd_pos := rv.RandInt(0, 49);
+ --pd_pos := 10;
+ for k in 1 to pd_pos loop
+ wait until abs_position'event;
+ end loop; -- k
+ run_pd_pulses(PD_PULSE_W, PD_PERIOD, true, emul_s, emul_m);
+
+ swathe_completed := false;
+ while swathe_completed = false loop
+ wait for 500 ns;
+ -- Check whether the encoder generation has completed
+ check_max_pulses_done(swathe_completed, emul_s, emul_m);
+ end loop;
+
+ wait for 25 us;
+ half_swathe_cnt <= half_swathe_cnt + 1;
+ wait until clk = '1' and clk'event;
+ end_of_swathe <= '1';
+ wait until clk = '1' and clk'event;
+ end_of_swathe <= '0';
+ -- reverse direction
+ if (enc_dir /= START_DIR) then
+ -- The number of iterations is doubled, to take into account POF and
+ -- EPD input types
+ if (swathe_cnt = 2*NUM_ITERATIONS - 1) then
+ end_of_stimuli := true;
+ else
+ swathe_cnt <= swathe_cnt + 1;
+ end if;
+ end if;
+ if (end_of_stimuli = false) then
+ wait until clk = '1' and clk'event;
+ if(enc_dir = DIR_0) then
+ enc_dir <= DIR_1;
+ else
+ enc_dir <= DIR_0;
+ end if;
+ -- Wait some time to make sure the change of direction is transmitted.
+ -- Note: if the position starts changing before the receiver was able to
+ -- confirm the change of direction, then some encoder pulses may not be
+ -- generated
+ wait for 1 us;
+ wait until clk = '1' and clk'event;
+ end if;
+ end loop; -- end_of_stimuli = false
+
+ stimuli_completed <= true;
+ wait;
+
+ end process pSTIMULI;
+
+ --
+ pGEN_EXT_PULSE : process
+ begin
+ ext_pulse <= '0';
+ if ext_pulse_enable = '0' then
+ wait until ext_pulse_enable = '1';
+ end if;
+ wait for 200 ns;
+ for n in 0 to 11 loop
+ ext_pulse <= '1';
+ if n = 5 or n = 6then
+ wait for 170 ns;
+ ext_pulse <= '0';
+ wait for 30 ns;
+ else
+ wait for 200 ns;
+ ext_pulse <= '0';
+ end if;
+ wait for 800 ns;
+ end loop; -- n
+ if ext_pulse_enable = '1' then
+ wait until ext_pulse_enable = '0';
+ end if;
+ end process pGEN_EXT_PULSE;
+
+ -----------------------------------------------------------------------------
+ -- Testbench Control
+ -----------------------------------------------------------------------------
+
+ dw <= pof_tx when run_dw = '1' else '0';
+
+ pOUT_CHECK_REGs : process(reset_n, clk)
+ begin
+ if(reset_n = '0') then
+ ch_pulse_out_d <= (others => '0');
+ loc_fp_cnt <= (others => 0);
+ dw_d <= '0';
+ dw_cnt <= 0;
+ elsif(clk = '1' and clk'event) then
+ ch_pulse_out_d <= ch_pulse_out;
+ for n in 0 to CH_NUM-1 loop
+ if(rst_fp_cnt = '1') then
+ loc_fp_cnt(n) <= 0;
+ elsif(ch_pulse_out(n) = '1' and ch_pulse_out_d(n) = '0') then
+ loc_fp_cnt(n) <= loc_fp_cnt(n) + 1;
+ end if;
+ end loop; -- n
+ -- Check the number of generated fire-requests at the end of the swathe
+ if(end_of_swathe = '1') then
+ for n in 0 to CH_NUM-1 loop
+ if(loc_fp_cnt(n) /= half_swathe_cnt*IMAGE_SIZE) then
+ log("ERROR on Channel CH" & integer'image(n) & ": Expected Fire-Requests = " & to_string(half_swathe_cnt*IMAGE_SIZE) & ", detected Fire-Requests = " & to_string(loc_fp_cnt(n)), VLOW, true);
+ error_flag := true;
+ end if;
+ end loop; -- n
+ end if;
+ dw_d <= dw;
+ if(run_dw = '0') then
+ dw_cnt <= 0;
+ elsif(dw = '1' and dw_d = '0') then
+ dw_cnt <= dw_cnt + 1;
+ end if;
+ end if;
+ end process pOUT_CHECK_REGs;
+
+ pTB_CTRL : process
+ type fp_arrived_t is array (0 to CH_NUM - 1) of boolean;
+ variable fp_arrived : fp_arrived_t;
+ type fp_arrived_pos_t is array (0 to CH_NUM - 1) of integer;
+ variable fp_arrived_pos : fp_arrived_pos_t;
+ variable fp_arrived_agg : integer;
+ variable pd_arrived_pos : integer;
+ alias pd_spy is <>;
+ alias abs_spy is <>;
+
+ begin
+
+ -- Set the verbosity level for logging
+ set_log_verbosity(VERBOSITY_LEVEL);
+ --set_log_verbosity(VHIGH);
+
+ log_header("Multi-channel FPM verification:", VLOW);
+
+ running <= false;
+ passed <= false;
+
+ error_flag := false;
+
+ -- Reset
+ reset_n <= '0';
+ wait for 100 ns;
+ wait until clk = '1' and clk'event;
+ reset_n <= '1';
+
+ if (configuring /= true) then
+ wait until configuring = true;
+ end if;
+ wait until configuring = false;
+ running <= true;
+
+ while stimuli_completed = false loop
+ wait until ((pd_spy = '1' and pd_spy'event) or stimuli_completed);
+
+ if (stimuli_completed) then
+ exit;
+ end if;
+
+ pd_arrived_pos := to_integer(signed(abs_spy));
+ for i in 0 to CH_NUM - 1 loop
+ fp_arrived(i) := false;
+ fp_arrived_pos(i) := 0;
+ end loop;
+ log("Product detect fired @ " & integer'image(pd_arrived_pos) & " ... ", VLOW, true);
+ fp_arrived_agg := 0;
+ while fp_arrived_agg < CH_NUM loop
+ fp_arrived_agg := 0;
+ for i in 0 to CH_NUM - 1 loop
+ if fp_arrived(i) = true then
+ fp_arrived_agg := fp_arrived_agg + 1;
+ end if;
+ end loop;
+
+ wait until (unsigned(ch_pulse_out) /= 0 or stimuli_completed);
+ if (stimuli_completed) then
+ exit;
+ end if;
+
+ for i in 0 to CH_NUM - 1 loop
+ if ch_pulse_out(i) = '1' and fp_arrived(i) = false then
+ fp_arrived(i) := true;
+ fp_arrived_pos(i) := to_integer(signed(abs_spy));
+ log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_pos(i)) & " ... ", VLOW, true);
+ if (abs (pd_arrived_pos - fp_arrived_pos(i)) /= ch_offset(i)) then
+ log("ERROR on Channel CH" & integer'image(i) & ": First Fire-Pulse detected at position " & to_string(fp_arrived_pos(i)) & ", expected position is " & to_string((pd_arrived_pos+ch_offset(i))), VLOW, true);
+ error_flag := true;
+ end if;
+ end if;
+ end loop;
+ end loop;
+ end loop;
+
+ if (stimuli_completed = true) then
+ -- wait enough time to make sure that a max length package can be propagated
+ wait for 20 us;
+ end if;
+
+ if (registers_read = false) then
+ wait until registers_read = true;
+ end if;
+
+ -- Report PD and FP counter from pulse generator
+ for i in 0 to CH_NUM - 1 loop
+ log("Channel CH" & integer'image(i) & " PD-in counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true);
+ log("Channel CH" & integer'image(i) & " FP-out counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true);
+ log("Channel CH" & integer'image(i) & " Detected Fire-Pulses : " & integer'image(loc_fp_cnt(i)) & " ... ", VLOW, true);
+ if(pd_cnt(i) /= (NUM_ITERATIONS) * 2 * 2) then -- fire_pulse_manager now has no registers beyond channel 0
+ log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true);
+ error_flag := true;
+ end if;
+ if((loc_fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 2 * IMAGE_SIZE) or (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 2 * IMAGE_SIZE)) then
+ log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true);
+ error_flag := true;
+ end if;
+ end loop;
+
+ wait until clk = '1' and clk'event;
+
+ running <= false;
+ passed <= true after 100 ns;
+ wait;
+
+ end process pTB_CTRL;
+
+ pFAILED : process
+ begin
+ failed <= false;
+ while true loop
+ wait for 1 us;
+ if(error_flag = true) then
+ failed <= true;
+ end if;
+ end loop;
+ end process pFAILED;
+
+ pREPORT_RESULT : process
+ begin
+ wait until failed = true or passed = true;
+ wait for 1 us;
+ log_separator_line(VLOW);
+ if(failed = true) then
+ log("FAILURE: test completed with errors.", VLOW);
+ elsif(passed = true) then
+ log("SUCCESS: test successfully completed.", VLOW);
+ end if;
+ log_separator_line(VLOW);
+ test_completed <= true;
+ end process pREPORT_RESULT;
+
+ pUUT_CTRL : process
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+
+ begin
+ sel_slave_0 <= '0';
+ sel_slave_1 <= '0';
+ rst_fp_cnt <= '0';
+ configuring <= true;
+
+ input_mode <= POF_INPUT;
+
+ run_dw <= '0';
+
+ -- Initialize avalon mm interfaces
+ mm_m_init(avs_m, use_waitrequest => true);
+
+ if (reset_n = '0') then
+ wait until reset_n = '1';
+ wait for 100 ns;
+ wait until clk = '1' and clk'event;
+ end if;
+
+ log("Driving external pulses ... ", VLOW, true);
+ ext_pulse_enable <= '1';
+ wait for 20 us;
+ ext_pulse_enable <= '0';
+ wait for 1 us;
+ wait until clk = '1' and clk'event;
+ rst_fp_cnt <= '1';
+ wait until clk = '1' and clk'event;
+ rst_fp_cnt <= '0';
+
+ log("Configuring POFTX ... ", VLOW, true);
+ sel_slave_1 <= '1';
+ -- enable the block
+ addr := std_logic_vector(to_unsigned(0, 32));
+ data := X"0000_0021";
+ mm_32b_write(addr, data, avs_s, avs_m);
+
+ sel_slave_1 <= '0';
+ sel_slave_0 <= '1';
+ wait until clk = '1' and clk'event;
+
+ log("Configuring FPM ... ", VLOW, true);
+
+ fpm_ctrl_config(avs_s, avs_m);
+
+ fpm_ems_config(avs_s, avs_m);
+
+ config_pg_l : for i in 0 to CH_NUM - 1 loop
+
+ pulse_gen_config(i, ch_offset(i), DIV_RATIO, SUBPIX_PHASES, IMAGE_SIZE, avs_s, avs_m);
+
+ end loop config_pg_l;
+
+ log("Configuration completed.", VLOW, true);
+ configuring <= false;
+
+ log_separator_line(VLOW);
+ log("POF input mode verification", VLOW, true);
+ log_separator_line(VLOW);
+
+ fpm_input_config(input_mode, avs_s, avs_m);
+
+ if(DRIVE_DROP_WATCH = true) then
+ drop_watch_config('1', "0001", 15, avs_s, avs_m);
+ end if;
+
+ while stimuli_completed = false loop
+ wait until reprogram_offset = true or stimuli_completed = true;
+ if (stimuli_completed) then
+ exit;
+ end if;
+
+ log("Reading counters ... ", VLOW, true);
+ -- Read PD and FP counter from pulse generator
+ for i in 0 to CH_NUM - 1 loop
+ fpm_reg_read(PG_CH_ID+i, work.pulse_generator_3_pkg.PD_CNT_REG, data, avs_s, avs_m);
+ pd_cnt(i) <= to_integer(unsigned(data));
+ fpm_reg_read(PG_CH_ID+i, work.pulse_generator_3_pkg.FIRE_REQ_CNT_REG, data, avs_s, avs_m);
+ fp_cnt(i) <= to_integer(unsigned(data));
+ wait until clk = '1' and clk'event;
+ log("CH-" & to_string(i) & ": pd_in_cnt = " & to_string(pd_cnt(i)) & ", fire_req_cnt = " & to_string(fp_cnt(i)) & ", detected fire-req-cnt = " & to_string(loc_fp_cnt(i)), VMEDIUM);
+ end loop;
+
+ configuring <= true;
+
+ -- Reprogram the input to EPD and repeat the same number of iterations
+ if (swathe_cnt = NUM_ITERATIONS) then
+ log_separator_line(VLOW);
+ log("EPD input mode verification", VLOW, true);
+ log_separator_line(VLOW);
+
+ input_mode <= EPD_INPUT;
+ wait until clk = '1' and clk'event;
+ fpm_input_config(input_mode, avs_s, avs_m);
+
+ if(DRIVE_DROP_WATCH = true) then
+ drop_watch_config('1', "0001", 15, avs_s, avs_m);
+ end if;
+
+ run_dw <= '1';
+ end if;
+
+ log("Reprogramming offset ... ", VLOW, true);
+ config_of_l : for i in 0 to CH_NUM - 1 loop
+ ch_offset_config(i, ch_offset(i), avs_s, avs_m);
+ end loop;
+ configuring <= false;
+ end loop;
+
+ log("Reading counters ... ", VLOW, true);
+ -- Read PD and FP counter from pulse generator
+ for i in 0 to CH_NUM - 1 loop
+ fpm_reg_read(PG_CH_ID+i, work.pulse_generator_3_pkg.PD_CNT_REG, data, avs_s, avs_m);
+ pd_cnt(i) <= to_integer(unsigned(data));
+ fpm_reg_read(PG_CH_ID+i, work.pulse_generator_3_pkg.FIRE_REQ_CNT_REG, data, avs_s, avs_m);
+ fp_cnt(i) <= to_integer(unsigned(data));
+ wait until clk = '1' and clk'event;
+ log("CH-" & to_string(i) & ": pd_in_cnt = " & to_string(pd_cnt(i)) & ", fire_req_cnt = " & to_string(fp_cnt(i)), VMEDIUM);
+ end loop;
+
+ registers_read <= true;
+
+ wait;
+ end process pUUT_CTRL;
+
+ clk_clk <= clk;
+ reset_reset_n <= reset_n;
+
+ avs_s.mm_readdata <= avs_readdata(0) when sel_slave_0 = '1' else
+ avs_readdata(1) when sel_slave_1 = '1' else (others => '0');
+
+ avs_s.mm_readdatavalid <= '0';
+
+ avs_s.mm_waitrequest <= avs_waitrequest(0) when sel_slave_0 = '1' else
+ avs_waitrequest(1) when sel_slave_1 = '1' else '0';
+
+ avs_address <= avs_m.mm_address(avs_address'range);
+ avs_write(0) <= avs_m.mm_write and sel_slave_0;
+ avs_write(1) <= avs_m.mm_write and sel_slave_1;
+ avs_writedata <= avs_m.mm_writedata;
+ avs_read(0) <= avs_m.mm_read and sel_slave_0;
+ avs_read(1) <= avs_m.mm_read and sel_slave_1;
+
+ -- Emulator Avalon bus maapings
+ emul_s.mm_readdata <= emul_readdata;
+ emul_s.mm_readdatavalid <= emul_readdatavalid;
+ emul_s.mm_waitrequest <= '0';
+
+ emul_address <= emul_m.mm_address(emul_address'range);
+ emul_writedata <= emul_m.mm_writedata;
+ emul_write <= emul_m.mm_write;
+ emul_read <= emul_m.mm_read;
+
+end behav;
+
diff --git a/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb_pkg.vhd b/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb_pkg.vhd
new file mode 100644
index 0000000..b9944da
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/test/fire_pulse_manager_7_tb_pkg.vhd
@@ -0,0 +1,827 @@
+-------------------------------------------------------------------------------
+-- Title : fire_pulse_manager_7_tb_pkg
+-- Project : SMB
+-------------------------------------------------------------------------------
+-- File : fire_pulse_manager_7_tb_pkg.vhd
+-- Author : Gianmarco Girau
+-- Company : Global Inkjet Systems
+-- Created : 2020-01-02
+-- Last update: 2021-01-06
+-- SVN ID : Git
+-- Standard : VHDL'2008
+-------------------------------------------------------------------------------
+-- Description:
+-- Support package for the FPM testbench
+-------------------------------------------------------------------------------
+
+--library std;
+--use std.textio.all;
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_textio.all;
+use ieee.numeric_std.all;
+use ieee.math_real.all;
+
+library work;
+use work.fire_pulse_7_pkg.all;
+use work.ems_0_pkg.all;
+use work.fpm_ctrl_7_pkg.all;
+
+library OSVVM ;
+use OSVVM.RandomBasePkg.all ;
+use OSVVM.RandomPkg.all;
+
+library work;
+use work.log_pkg.all;
+use work.avalon_verify_pkg_2.all;
+use work.enc_pd_emul_1_pkg.all;
+
+package fire_pulse_manager_7_tb_pkg is
+
+ constant CLK_PERIOD : time := 10.0 ns;
+ constant CLK_FREQ : real := 100.0e6;
+
+ constant CH_NUM : integer := 4;
+ constant BLK_NUM : natural := 6 + CH_NUM;
+
+ constant ENC_NCO_WIDTH : positive := 32;
+
+ -- Logging Verbosity Level
+ constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
+
+ type fpm_input_type_t is (POF_INPUT, EPD_INPUT, INTERNAL);
+
+ -----------------------------------------------------------------------------
+ -- FPM Configuration
+ -----------------------------------------------------------------------------
+
+ -- fpm_reg_write with addr defined as std_logic_vector
+ procedure fpm_reg_write(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in std_logic_vector;
+ data : in std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ -- fpm_reg_write with addr defined as integer
+ procedure fpm_reg_write(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in integer;
+ data : in std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ -- fpm_reg_read with addr defined as std_logic_vector
+ procedure fpm_reg_read(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in std_logic_vector;
+ data : out std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ -- fpm_reg_read with addr defined as integer
+ procedure fpm_reg_read(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in integer;
+ data : out std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure fpm_ctrl_config(
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure ch_offset_config(
+ ch_id : in natural;
+ ch_offset : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure ch_ctrl_config(
+ ch_id : in natural;
+ pixel_num : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure pulse_gen_config(
+ ch_id : in natural;
+ ch_offset : in natural;
+ div_ratio : in real;
+ subpix_phases : in natural;
+ pixel_num : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure fpm_input_config(
+ input_type : in fpm_input_type_t;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure fpm_ems_config(
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ procedure drop_watch_config(
+ enable : in std_logic;
+ src : in std_logic_vector(3 downto 0);
+ pulse_witdth : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t);
+
+ -----------------------------------------------------------------------------
+ -- ENC/PD Emulator Configuration
+ -----------------------------------------------------------------------------
+
+ type enc_phase_t is (SINGLE_PHASE, DUAL_PHASE);
+ type enc_edge_t is (RISING, FALLING, RISING_AND_FALLING);
+ type pd_edge_t is (RISING, FALLING, RISING_AND_FALLING);
+ subtype enc_freq_t is real range 0.0e3 to 10.0e6;
+ subtype pd_pulse_width_t is real range 0.0 to 1000.0; -- PD period in us
+ --subtype pd_period_t is real range 50.0 to 1.0e6; -- PD period in us
+ subtype pd_period_t is real range 0.5 to 1.0e6; -- PD period in us
+
+ type enc_dir_t is (DIR_0, DIR_1);
+
+ type emul_cfg_t is record
+
+ enc_res : real;
+ enc_ppr : integer;
+ enc_phase : enc_phase_t;
+ enc_edge : enc_edge_t;
+ enc_dir : enc_dir_t;
+ pd_edge : pd_edge_t;
+ enc_freq : enc_freq_t;
+ pd_pulse_w : pd_pulse_width_t;
+ pd_period : pd_period_t;
+ enc_pulses : integer;
+
+ end record emul_cfg_t;
+
+ -- set abs-pos
+ procedure set_enc_abs_pos(
+ abs_pos : in std_logic_vector(39 downto 0);
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ -- The ENC/PD emulator configuration is derived from the EMS
+ procedure apply_enc_pd_emul_cfg(
+ cfg : in emul_cfg_t;
+ init : in boolean := true;
+ run_pulses_mode : in boolean := false;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ -- Stop the ENC/PD emulator
+ procedure stop_enc_pd_emul(
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ procedure check_max_pulses_done(
+ done : out boolean;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ -- Run a fix number of encoder pulses
+ procedure run_enc_pulses(
+ enc_freq : in enc_freq_t;
+ direction : in enc_dir_t;
+ double_ph_mode : in boolean := true;
+ num_pulses : in integer;
+ enc_ppr : in integer;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ -- Run PD pulses: either single pulse or periodic mode
+ procedure run_pd_pulses(
+ pulse_width : in pd_pulse_width_t;
+ pd_period : in pd_period_t;
+ single_pulse_mode : in boolean := false;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t);
+
+ -----------------------------------------------------------------------------
+ -- Support functions
+ -----------------------------------------------------------------------------
+
+ -- generate the NCO increment corresponding to a given output frequency
+ function freq2NCO_inc(
+ f_out : real; f_clk : real) return std_logic_vector;
+
+end fire_pulse_manager_7_tb_pkg;
+
+package body fire_pulse_manager_7_tb_pkg is
+
+ -----------------------------------------------------------------------------
+ -- FPM Configuration
+ -----------------------------------------------------------------------------
+
+ -- fpm_reg_write with addr defined as std_logic_vector
+ procedure fpm_reg_write(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in std_logic_vector;
+ data : in std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable address : std_logic_vector(31 downto 0);
+
+ begin
+
+ address := std_logic_vector(to_unsigned(blk_id*BLK_SIZE+to_integer(unsigned(addr)),32));
+ mm_32b_write(address, data, mm_s, mm_m);
+
+ end procedure fpm_reg_write;
+
+ -- fpm_reg_write with addr defined as integer
+ procedure fpm_reg_write(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in integer;
+ data : in std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable address : std_logic_vector(31 downto 0);
+
+ begin
+
+ address := std_logic_vector(to_unsigned((blk_id*BLK_SIZE)+addr,32));
+ mm_32b_write(address, data, mm_s, mm_m);
+
+ end procedure fpm_reg_write;
+
+ -- fpm_reg_read with addr defined as std_logic_vector
+ procedure fpm_reg_read(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in std_logic_vector;
+ data : out std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable address : std_logic_vector(31 downto 0);
+
+ begin
+
+ address := std_logic_vector(to_unsigned(blk_id*BLK_SIZE+to_integer(unsigned(addr)),32));
+ mm_32b_read(address, data, mm_s, mm_m);
+
+ end procedure fpm_reg_read;
+
+ -- fpm_reg_read with addr defined as std_logic_vector
+ procedure fpm_reg_read(
+ blk_id : in natural range 0 to BLK_NUM-1;
+ addr : in integer;
+ data : out std_logic_vector(31 downto 0);
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable address : std_logic_vector(31 downto 0);
+
+ begin
+
+ address := std_logic_vector(to_unsigned((blk_id*BLK_SIZE)+addr,32));
+ mm_32b_read(address, data, mm_s, mm_m);
+
+ end procedure fpm_reg_read;
+
+ procedure fpm_ctrl_config(
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+
+ begin
+
+ log("Configuring FPM Controller ... ", VMEDIUM, true);
+ -- Enable the POF-Rx
+ data := X"0000_0001";
+ fpm_reg_write(FP_CTRL_ID, CSR_POF_RECEIVER_CONTROL_ADDR_INT, data, mm_s, mm_m);
+
+ fpm_reg_read(FP_CTRL_ID, CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+
+ -- Select the input source
+ data(2 downto 0) := b"001";
+ fpm_reg_write(FP_CTRL_ID, CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+
+ end procedure fpm_ctrl_config;
+
+ procedure ch_offset_config(
+ ch_id : in natural;
+ ch_offset : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+
+ begin
+
+ -- Disable/Re-enable first the whole pulse_generator
+ data := std_logic_vector(to_unsigned(ch_offset, 32));
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.CH_OFFSET_D0_REG, data, mm_s, mm_m);
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.CH_OFFSET_D1_REG, data, mm_s, mm_m);
+
+ log("CH-" & to_string(ch_id) & ": PD offset configured to " & to_string(ch_offset) & ".", VMEDIUM);
+
+ end procedure ch_offset_config;
+
+ procedure ch_ctrl_config(
+ ch_id : in natural;
+ pixel_num : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+ variable ram_idx : natural;
+ variable ram_offset : natural;
+
+ begin
+
+ ram_offset := to_integer(unsigned(work.pulse_generator_3_pkg.SEQ_RAM_OFFSET));
+ ram_idx := 0;
+
+ -- Issue first an image on DIR-0, then on DIR-1
+ -- Reset the vector output value
+ data := X"30000000";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Enable Trigger Mask (All the triggers)
+ data := X"1000000F";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Wait for a single PD event
+ data := X"20000001";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Issue a request to generate 'pixel_num' fire requests
+ data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"24";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"00";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- wait until the end of the image
+ data := X"23000001";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Switch to DIR-1
+ data := X"30000001";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Wait for a single PD event
+ data := X"20000001";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Issue a request to generate 'pixel_num' fire requests
+ data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"25";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"01";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- wait until the end of the image
+ data := X"23000001";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+ -- Jump to DIR-0
+ data := X"C0000000";
+ fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m);
+ ram_idx := ram_idx + 1;
+
+ end procedure ch_ctrl_config;
+
+ procedure pulse_gen_config(
+ ch_id : in natural;
+ ch_offset : in natural;
+ div_ratio : in real;
+ subpix_phases : in natural;
+ pixel_num : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+ variable ratio_int : integer;
+ variable ratio_slv : std_logic_vector(33 downto 0);
+
+ begin
+
+ log("Configuring Channel " & to_string(ch_id) & " ... ", VMEDIUM, true);
+
+ -- Disable/Re-enable first the whole pulse_generator
+ data := (others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.PULSE_GEN_CTRL_REG, data, mm_s, mm_m);
+ data := (0 => '1', 16 => '1', others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.PULSE_GEN_CTRL_REG, data, mm_s, mm_m);
+
+ -- Disable/Re-enable the Channel Controller sequencer
+ data := (others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, to_integer(unsigned(work.pulse_generator_3_pkg.SEQ_CSR_OFFSET)) + 3, data, mm_s, mm_m);
+ data := (0 => '1', others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, to_integer(unsigned(work.pulse_generator_3_pkg.SEQ_CSR_OFFSET)) + 3, data, mm_s, mm_m);
+
+ -- Set the number of sub-pixel phases
+ data := std_logic_vector(to_unsigned(subpix_phases, 32));
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.SUBPIXEL_PHASE_REG, data, mm_s, mm_m);
+
+ -- set the division ratio
+ ratio_int := integer((div_ratio / real(subpix_phases)) * real(2**24));
+ ratio_slv := std_logic_vector(to_unsigned(ratio_int, 34));
+ -- Set the integer part of the div-ratio
+ data(31 downto 10) := (others => '0');
+ data(9 downto 0) := ratio_slv(33 downto 24);
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.DIV_RATIO_INT, data, mm_s, mm_m);
+ data(31 downto 24) := (others => '0');
+ data(23 downto 0) := ratio_slv(23 downto 0);
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.DIV_RATIO_FRAC, data, mm_s, mm_m);
+ -- Disable/Enable the fractional divider
+ data := (others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.FRAC_DIV_CTRL_REG, data, mm_s, mm_m);
+ data := (0 => '1', others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.FRAC_DIV_CTRL_REG, data, mm_s, mm_m);
+
+ -- configure the channel offset
+ ch_offset_config(ch_id, ch_offset, mm_s, mm_m);
+
+ -- Configure the sequencer RAM
+ ch_ctrl_config(ch_id, pixel_num, mm_s, mm_m);
+
+ -- Restart the sequencer
+ data := (others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.CH_CTRL_CTRL_REG, data, mm_s, mm_m);
+ data := (0 => '1', others => '0');
+ fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_3_pkg.CH_CTRL_CTRL_REG, data, mm_s, mm_m);
+
+ end procedure pulse_gen_config;
+
+ procedure fpm_input_config(
+ input_type : in fpm_input_type_t;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+
+ begin
+
+
+
+ if(input_type = POF_INPUT) then
+
+ fpm_reg_read(FP_CTRL_ID, CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+
+ data(2 downto 0) := b"001";
+ fpm_reg_write(FP_CTRL_ID, CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+ log("FPM input set to POF. ", VLOW, true);
+
+ elsif(input_type = EPD_INPUT) then
+
+ data(2 downto 0) := b"101";
+ fpm_reg_write(FP_CTRL_ID, CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+ log("FPM input set to EPD. ", VLOW, true);
+
+ end if;
+
+ end procedure fpm_input_config;
+
+
+ procedure fpm_ems_config(
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+
+ begin
+
+ log("Configuring EMS ... ", VMEDIUM, true);
+
+ -- EMS software init
+ fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"1", mm_s, mm_m);
+
+ -- disable the EMS during the configuration
+ fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"0", mm_s, mm_m);
+
+ -- apply EMS config
+ fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_CONFIG_ADDR, 32x"3E0", mm_s, mm_m);
+
+ -- enable the EMS
+ fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"E", mm_s, mm_m);
+
+ end procedure fpm_ems_config;
+
+ procedure drop_watch_config(
+ enable : in std_logic;
+ src : in std_logic_vector(3 downto 0);
+ pulse_witdth : in natural;
+ signal mm_s : in mm_s_rec_t;
+ signal mm_m : out mm_m_rec_t) is
+
+ variable data : std_logic_vector(31 downto 0);
+
+ begin
+
+ -- configure the drop-watch
+ data := std_logic_vector(to_unsigned(pulse_witdth, 16)) & X"000" & src;
+ fpm_reg_write(FP_CTRL_ID, work.fpm_ctrl_7_pkg.CSR_DROP_WATCH_CONFIG_ADDR_INT, data, mm_s, mm_m);
+
+ -- Enable/disable the drop-watch
+ fpm_reg_read(FP_CTRL_ID, work.fpm_ctrl_7_pkg.CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+ data(3) := enable;
+ fpm_reg_write(FP_CTRL_ID, work.fpm_ctrl_7_pkg.CSR_SIGNAL_SELECTION_ADDR_INT, data, mm_s, mm_m);
+
+ if(enable = '1') then
+ log("Drop-Watch output enable on channel " & to_string(to_integer(unsigned(src))) & ".", VMEDIUM, true);
+ else
+ log("Drop-Watch output disabled.", VMEDIUM, true);
+ end if;
+
+ end procedure drop_watch_config;
+
+ -----------------------------------------------------------------------------
+ -- ENC/PD Emulator Configuration
+ -----------------------------------------------------------------------------
+
+ procedure set_enc_abs_pos(
+ abs_pos : in std_logic_vector(39 downto 0);
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+
+ begin
+
+ -- set the value for MSBs
+ addr:= std_logic_vector(resize(unsigned(CSR_POS_INIT_MSB_ADDR), 32));
+ mm_32b_write(addr, 24x"0" & abs_pos(39 downto 32), mm_s_rec, mm_m_rec);
+ -- set the value for LSBs
+ addr:= std_logic_vector(resize(unsigned(CSR_POS_INIT_LSB_ADDR), 32));
+ mm_32b_write(addr, abs_pos(31 downto 0), mm_s_rec, mm_m_rec);
+ -- read back the encoder configuration, then apply the set_abs_pos control
+ -- bit
+ addr:= std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32));
+ mm_32b_read(addr, data, mm_s_rec, mm_m_rec);
+ data(3) := '1';
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ log("Encoder/PD emulator abs-pos preset to " & to_string(to_integer(signed(abs_pos))) & ".", VMEDIUM);
+
+
+ end procedure set_enc_abs_pos;
+
+ procedure apply_enc_pd_emul_cfg(
+ cfg : in emul_cfg_t;
+ init : in boolean := true;
+ run_pulses_mode : in boolean := false;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+ variable data_check : std_logic_vector(31 downto 0) := (others => '0');
+ --
+ variable pd_low_period : real := 0.0; -- PD low period (ns)
+ variable pd_high_period : real := 0.0; -- PD high period (ns)
+
+ begin
+
+ -- Set the NCO inc: output freq
+ addr:= std_logic_vector(resize(unsigned(CSR_ENC_NCO_INC_ADDR), 32));
+ data := freq2NCO_inc(real(cfg.enc_freq), CLK_FREQ);
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- set the max pulses register
+ addr := std_logic_vector(resize(unsigned(CSR_PULSE_NUM_ADDR), 32));
+ data := std_logic_vector(to_unsigned(cfg.enc_pulses, 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- set the zero-phase ppr number
+ addr := std_logic_vector(resize(unsigned(CSR_ZP_PPR_ADDR), 32));
+ data := std_logic_vector(to_unsigned(cfg.enc_ppr, 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- Enable only the necessary outputs:
+ if(cfg.enc_phase = DUAL_PHASE ) then
+ data := 32x"FF";
+ else
+ data := 32x"BB";
+ end if;
+ addr := std_logic_vector(resize(unsigned(CSR_OUT_ENABLE_ADDR), 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32));
+ if(init = true) then
+ mm_32b_write(addr, 32x"2", mm_s_rec, mm_m_rec);
+ end if;
+
+ data := (others => '0');
+ if(run_pulses_mode = true) then
+ data(4) := '1';
+ end if;
+ if(cfg.enc_dir = DIR_0) then
+ data(2) := '0';
+ else
+ data(2) := '1';
+ end if;
+
+ -- enable the encoder
+ data(0) := '1';
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ log("Encoder/PD emulator enabled.", VMEDIUM);
+
+ end procedure apply_enc_pd_emul_cfg;
+
+ -- Stop the ENC/PD emulator
+ procedure stop_enc_pd_emul(
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+
+ begin
+
+ -- Disable PD emulation
+ addr := std_logic_vector(resize(unsigned(CSR_PD_CTRL_ADDR), 32));
+ mm_32b_read(addr, data, mm_s_rec, mm_m_rec);
+ data(0) := '0';
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- Disable Enc emulation
+ addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32));
+ mm_32b_read(addr, data, mm_s_rec, mm_m_rec);
+ data(0) := '0';
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ end procedure stop_enc_pd_emul;
+
+ -- Check whether the generation of a fixed number of encoder pulses has completed
+ procedure check_max_pulses_done(
+ done : out boolean;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+
+ begin
+
+ addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32));
+ mm_32b_read(addr, data, mm_s_rec, mm_m_rec);
+
+ if(data(6) = '1') then
+ done := true;
+ else
+ done := false;
+ end if;
+
+ end procedure check_max_pulses_done;
+
+ -- Run a fix number of encoder pulses
+ procedure run_enc_pulses(
+ enc_freq : in enc_freq_t;
+ direction : in enc_dir_t;
+ double_ph_mode : in boolean := true;
+ num_pulses : in integer;
+ enc_ppr : in integer;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+ variable data_check : std_logic_vector(31 downto 0) := (others => '0');
+
+ begin
+
+ -- Set the NCO inc: output freq
+ addr := std_logic_vector(resize(unsigned(CSR_ENC_NCO_INC_ADDR), 32));
+ data := freq2NCO_inc(real(enc_freq), CLK_FREQ);
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- set the max pulses register
+ addr := std_logic_vector(resize(unsigned(CSR_PULSE_NUM_ADDR), 32));
+ data := std_logic_vector(to_unsigned(num_pulses, 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- set the zero-phase ppr number
+ addr := std_logic_vector(resize(unsigned(CSR_ZP_PPR_ADDR), 32));
+ data := std_logic_vector(to_unsigned(enc_ppr, 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- Enable only the necessary outputs:
+ if(double_ph_mode = true) then
+ data := 32x"FF";
+ else
+ data := 32x"BB";
+ end if;
+ addr := std_logic_vector(resize(unsigned(CSR_OUT_ENABLE_ADDR), 32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32));
+ data := (4 => '1', 5 => '1', others => '0');
+ if(direction = DIR_0) then
+ data(2) := '0';
+ else
+ data(2) := '1';
+ end if;
+
+ -- enable the encoder
+ data(0) := '1';
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ --log("Running encoder pulses ... ", VMEDIUM);
+
+ end procedure run_enc_pulses;
+
+ -- Run PD pulses: either single pulse or periodic mode
+ procedure run_pd_pulses(
+ pulse_width : in pd_pulse_width_t;
+ pd_period : in pd_period_t;
+ single_pulse_mode : in boolean := false;
+ signal mm_s_rec : in mm_s_rec_t;
+ signal mm_m_rec : out mm_m_rec_t) is
+
+ variable addr : std_logic_vector(31 downto 0) := (others => '0');
+ variable data : std_logic_vector(31 downto 0) := (others => '0');
+ variable data_check : std_logic_vector(31 downto 0) := (others => '0');
+ variable tmp_val : integer;
+ variable idx : integer;
+ variable loop_idx : integer;
+
+ begin
+
+ -- set the pulse width
+ addr := std_logic_vector(resize(unsigned(CSR_PD_PULSE_W_ADDR), 32));
+ data := std_logic_vector(to_unsigned(integer(pulse_width*100.0),32));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
+
+ -- No need to use the sequerncer for a single pulse
+ if(single_pulse_mode = true) then
+ addr := std_logic_vector(resize(unsigned(CSR_PD_CTRL_ADDR), 32));
+ mm_32b_write(addr, 32x"3", mm_s_rec, mm_m_rec);
+ log("Issued single PD pulse. ", VMEDIUM);
+ return;
+ end if;
+
+ -- Use the sequencer to generate periodic pulses (here the periodicity is
+ -- in time): First program the sequencer RAM with instructions to generate
+ -- pulses with the specified periodicity, then enable the sequencer,
+ -- finally trigger the start of the procedure:
+
+ -- Write in the Emulator sequencer a simple procedure to issue PD pulses
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+0, 32));
+ mm_32b_write(addr, X"100000FF", mm_s_rec, mm_m_rec); -- Enable triggers
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+1, 32));
+ mm_32b_write(addr, X"30000000", mm_s_rec, mm_m_rec); -- All the outputs to zero
+ idx := 2;
+ loop_idx := idx;
+ if(pd_period >= 1.0) then
+ -- add a first trigger-wait instruction for 1-us pulses
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32));
+ tmp_val := integer(pd_period);
+ data := X"21000" & std_logic_vector(to_unsigned(tmp_val, 12));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec); -- trig_wait (us pulses)
+ idx := idx + 1;
+ end if;
+ -- add a second trigger on single clock cycle events
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32));
+ tmp_val := integer((pd_period-floor(pd_period))*100.0);
+ data := X"20000" & std_logic_vector(to_unsigned(tmp_val, 12));
+ mm_32b_write(addr, data, mm_s_rec, mm_m_rec); -- trig_wait (clk pulses)
+ idx := idx + 1;
+ -- issue the PD pulse
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32));
+ mm_32b_write(addr, X"31000001", mm_s_rec, mm_m_rec); -- All the outputs to zero
+ idx := idx + 1;
+ -- Jump to the beginning of the loop
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32));
+ mm_32b_write(addr, X"31000001", mm_s_rec, mm_m_rec); -- All the outputs to zero
+
+ -- Enable the sequencer
+ addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32));
+ mm_32b_write(addr, 32x"1", mm_s_rec, mm_m_rec); -- All the outputs to zero
+
+ -- issue a start-request to the sequencer
+ addr := std_logic_vector(resize(unsigned(CSR_SEQ_CTRL_ADDR), 32));
+ data(0) := '1'; -- start-request bit
+ data(24 downto 16) := 9x"0"; -- EAM sequence start-address
+ mm_32b_write(addr, 32x"1", mm_s_rec, mm_m_rec);
+
+ log("Running PD pulses ... ", VMEDIUM);
+
+ end procedure run_pd_pulses;
+
+ -----------------------------------------------------------------------------
+ -- Support functions
+ -----------------------------------------------------------------------------
+
+ -- generate the NCO increment corresponding to a given output frequency
+ function freq2NCO_inc(
+ f_out : real; f_clk : real) return std_logic_vector is
+ variable nco_inc : std_logic_vector(ENC_NCO_WIDTH-1 downto 0);
+
+ begin
+ nco_inc := std_logic_vector(to_unsigned(integer((f_out/f_clk)*(2.0**ENC_NCO_WIDTH)),ENC_NCO_WIDTH));
+ return nco_inc;
+
+ end function freq2NCO_inc;
+
+end fire_pulse_manager_7_tb_pkg;
diff --git a/generic_ip/fire_pulse_manager/7/src/test/led_tb.vhd b/generic_ip/fire_pulse_manager/7/src/test/led_tb.vhd
new file mode 100644
index 0000000..57bcb69
--- /dev/null
+++ b/generic_ip/fire_pulse_manager/7/src/test/led_tb.vhd
@@ -0,0 +1,633 @@
+-------------------------------------------------------------------------------
+-- Title : led_tb
+-- Project : FPM
+-------------------------------------------------------------------------------
+-- File : led_tb.vhd
+-- Author : GMG
+-- Company : Global Inkjet Systems
+-- Created : 2018-06-12
+-- Last update: 2020-01-20
+-- SVN ID : Git
+-- Standard : VHDL'2008
+-------------------------------------------------------------------------------
+-- Description:
+-- Testbench for the FPM LED generator
+-------------------------------------------------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.log_pkg.all;
+
+entity led_tb is
+ -- ..
+end entity led_tb;
+
+architecture behav of led_tb is
+
+ constant CLK_PERIOD : time := 10 ns;
+
+ constant CLK_FREQ : real := 100.0e6; -- target clock frequency
+
+ -- Logging Verbosity Level
+ constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
+
+ constant MAX_SIM_TIME : time := 50.0 ms; -- Maximum simulation time
+
+ constant MAX_PERIOD_MS : natural := 5;
+ constant GREEN_PERIOD_MS : natural := 2;
+
+ constant RUN_ENC_TEST : boolean := true;
+ constant RUN_PD_TEST : boolean := true;
+ constant RUN_POF_TEST : boolean := true;
+
+
+ signal reset_n : std_logic := '0';
+ signal clk : std_logic := '0';
+ --
+ signal init : std_logic;
+ signal pd : std_logic;
+ signal enc_p1 : std_logic;
+ signal enc_p2 : std_logic;
+ signal pof : std_logic;
+ signal all_ok : std_logic;
+ signal led_pd_g : std_logic;
+ signal led_pd_y : std_logic;
+ signal led_pd_r : std_logic;
+ signal led_enc_p1_g : std_logic;
+ signal led_enc_p1_y : std_logic;
+ signal led_enc_p1_r : std_logic;
+ signal led_enc_p2_g : std_logic;
+ signal led_enc_p2_y : std_logic;
+ signal led_enc_p2_r : std_logic;
+ signal led_pof_g : std_logic;
+ signal led_pof_y : std_logic;
+ signal led_pof_r : std_logic;
+
+ -- TB specific signals
+ signal setup : boolean;
+ signal running : boolean;
+ signal passed : boolean := false;
+ signal failed : boolean := false;
+ signal test_timeout : boolean := false;
+ signal test_completed : boolean := false;
+
+ signal error_flag : boolean;
+
+begin -- architecture behav
+
+ clk <= not clk after 0.5*CLK_PERIOD;
+
+ -----------------------------------------------------------------------------
+ -- LED Generator (UUT)
+ -----------------------------------------------------------------------------
+
+ iUUT: entity work.seb_epd_led_gen_6
+ generic map (
+ MAX_PERIOD_MS => MAX_PERIOD_MS,
+ GREEN_PERIOD_MS => GREEN_PERIOD_MS)
+ port map (
+ reset_n => reset_n,
+ clk => clk,
+ init => init,
+ pd => pd,
+ enc_p1 => enc_p1,
+ enc_p2 => enc_p2,
+ pof => pof,
+ all_ok => all_ok,
+ led_pd_g => led_pd_g,
+ led_pd_y => led_pd_y,
+ led_pd_r => led_pd_r,
+ led_enc_p1_g => led_enc_p1_g,
+ led_enc_p1_y => led_enc_p1_y,
+ led_enc_p1_r => led_enc_p1_r,
+ led_enc_p2_g => led_enc_p2_g,
+ led_enc_p2_y => led_enc_p2_y,
+ led_enc_p2_r => led_enc_p2_r,
+ led_pof_g => led_pof_g,
+ led_pof_y => led_pof_y,
+ led_pof_r => led_pof_r);
+
+
+ -----------------------------------------------------------------------------
+ -- Testbench Logic
+ -----------------------------------------------------------------------------
+
+ pTEST_PROC : process
+
+ begin
+
+ ---------------------------------------------------------------------------
+ -- Initialize & Configure
+ ---------------------------------------------------------------------------
+
+ reset_n <= '0';
+
+ init <= '0';
+
+ setup <= false;
+
+ running <= false;
+ error_flag <= false;
+
+ --Set the verbosity level for logging
+ set_log_verbosity(VERBOSITY_LEVEL);
+
+ pd <= '0';
+ enc_p1 <= '0';
+ enc_p2 <= '0';
+ pof <= '0';
+ all_ok <= '0';
+
+ wait for 100 ns;
+ reset_n <= '1';
+
+ wait for 100 ns;
+ wait until clk = '1' and clk'event;
+ all_ok <= '1';
+
+ -- Nothing really to do here
+ setup <= true;
+
+ ---------------------------------------------------------------------------
+ -- Running
+ ---------------------------------------------------------------------------
+
+ running <= true;
+ log_separator_line(VLOW);
+ log("FPM (SEB-EPD) LEDs verification:", VLOW);
+ log_separator_line(VLOW);
+
+ wait for 0.5 ms;
+
+ ---------------------------------------------------------------------------
+ -- POF LED
+ ---------------------------------------------------------------------------
+
+ if(RUN_POF_TEST = true) then
+
+ log_separator_line(VLOW);
+ log("Testing POF LED:", VLOW);
+ wait for 5 us;
+
+ if(led_pof_r /= '0') then
+ log("ERROR: POF Red LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_g /= '0') then
+ log("ERROR: POF Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 5 us;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+
+ wait for 100 ns;
+ if(led_pof_g /= '1') then
+ log("ERROR: POF Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pof_g /= '0') then
+ log("ERROR: POF Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pof_g /= '0') then
+ log("ERROR: POF Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '1') then
+ log("ERROR: POF Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 5 us;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+
+ wait for 100 ns;
+ if(led_pof_g /= '1') then
+ log("ERROR: POF Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ for n in 0 to 8 loop
+ wait for 10 us;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+ wait until clk = '1' and clk'event;
+ pof <= not pof;
+ end loop; -- n
+
+ wait for 100 ns;
+ if(led_pof_g /= '1') then
+ log("ERROR: POF Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pof_g /= '0') then
+ log("ERROR: POF Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '0') then
+ log("ERROR: POF Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pof_g /= '0') then
+ log("ERROR: POF Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pof_y /= '1') then
+ log("ERROR: POF Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 50 ns;
+ if(error_flag = false) then
+ log("POF LEDs are OK.", VLOW);
+ end if;
+
+ wait for 0.5 ms;
+
+ end if; -- RUN_POF_TEST
+
+ ---------------------------------------------------------------------------
+ -- PD LEDs
+ ---------------------------------------------------------------------------
+
+ if(RUN_PD_TEST = true) then
+
+ log_separator_line(VLOW);
+ log("Testing PD LEDs:", VLOW);
+
+ pd <= '1';
+
+ wait for 100 ns;
+ if(led_pd_g /= '1') then
+ log("ERROR: PD Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '0') then
+ log("ERROR: PD Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 1 us;
+ pd <= '0';
+ wait for 1 us;
+
+ wait for 3 ms;
+ if(led_pd_g /= '0') then
+ log("ERROR: PD Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '0') then
+ log("ERROR: PD Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pd_g /= '0') then
+ log("ERROR: PD Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '1') then
+ log("ERROR: PD Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 1.5 ms;
+
+ pd <= '1';
+ wait for 1 us;
+ pd <= '0';
+ wait for 10 us;
+ pd <= '1';
+ wait for 1 us;
+ pd <= '0';
+ wait for 10 us;
+ pd <= '1';
+ wait for 1 us;
+ pd <= '0';
+ wait for 10 us;
+ pd <= '1';
+ wait for 1 us;
+ pd <= '0';
+
+ if(led_pd_g /= '1') then
+ log("ERROR: PD Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '0') then
+ log("ERROR: PD Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3.0 ms;
+
+ if(led_pd_g /= '0') then
+ log("ERROR: PD Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '0') then
+ log("ERROR: PD Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_pd_g /= '0') then
+ log("ERROR: PD Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_pd_y /= '1') then
+ log("ERROR: PD Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 50 ns;
+ if(error_flag = false) then
+ log("PD LEDs are OK.", VLOW);
+ end if;
+
+ wait for 0.5 ms;
+
+ end if; -- RUN_PD_TEST
+
+ ---------------------------------------------------------------------------
+ -- Encoder LEDs
+ ---------------------------------------------------------------------------
+
+ if(RUN_ENC_TEST = true) then
+
+ log_separator_line(VLOW);
+ log("Testing Encoder LEDs:", VLOW);
+ wait for 5 us;
+
+ if(led_enc_p1_y /= '0') then
+ log("ERROR: P1 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ if(led_enc_p2_y /= '0') then
+ log("ERROR: P2 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ if(led_enc_p1_g /= '0') then
+ log("ERROR: P1 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ if(led_enc_p2_g /= '0') then
+ log("ERROR: P2 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ if(led_enc_p1_r /= '0') then
+ log("ERROR: P1 Red LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ if(led_enc_p2_r /= '0') then
+ log("ERROR: P2 Red LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 1 us;
+
+ enc_p1 <= '1';
+ wait for 10 us;
+ enc_p2 <= '1';
+ wait for 100 ns;
+
+ if(led_enc_p1_g /= '1') then
+ log("ERROR: P1 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_g /= '1') then
+ log("ERROR: P2 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p1_y /= '0') then
+ log("ERROR: P1 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '0') then
+ log("ERROR: P2 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_enc_p1_g /= '0') then
+ log("ERROR: P1 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_g /= '0') then
+ log("ERROR: P2 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p1_y /= '0') then
+ log("ERROR: P1 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '0') then
+ log("ERROR: P2 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_enc_p1_g /= '0') then
+ log("ERROR: P1 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_g /= '0') then
+ log("ERROR: P2 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p1_y /= '1') then
+ log("ERROR: P1 Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '1') then
+ log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 20 us;
+
+ enc_p1 <= '0';
+ wait for 100 ns;
+ if(led_enc_p1_g /= '1') then
+ log("ERROR: P1 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_enc_p1_g /= '0') then
+ log("ERROR: P1 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 5 us;
+ enc_p1 <= '1';
+ wait for 100 ns;
+ if(led_enc_p1_g /= '1') then
+ log("ERROR: P1 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ wait for 10 us;
+ enc_p1 <= '0';
+ wait for 10 us;
+ enc_p1 <= '1';
+ wait for 10 us;
+ enc_p1 <= '0';
+ wait for 10 us;
+ enc_p1 <= '1';
+ wait for 10 us;
+ if(led_enc_p1_g /= '1') then
+ log("ERROR: P1 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 200 us;
+ enc_p2 <= '0';
+ wait for 100 ns;
+ if(led_enc_p2_g /= '1') then
+ log("ERROR: P2 Green LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_enc_p2_g /= '0') then
+ log("ERROR: P2 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '0') then
+ log("ERROR: P2 Yellow LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 3 ms;
+ if(led_enc_p2_g /= '0') then
+ log("ERROR: P2 Green LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '1') then
+ log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 10 us;
+ enc_p2 <= not enc_p2;
+ enc_p1 <= not enc_p1;
+ wait for 100 ns;
+ if(led_enc_p1_r /= '1') then
+ log("ERROR: P1 Red LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_r /= '1') then
+ log("ERROR: P2 Red LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 6 ms;
+ wait for 100 ns;
+ if(led_enc_p1_r /= '0') then
+ log("ERROR: P1 Red LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_r /= '0') then
+ log("ERROR: P2 Red LED must be LOW.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p1_y /= '1') then
+ log("ERROR: P1 Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+ if(led_enc_p2_y /= '1') then
+ log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
+ error_flag <= true;
+ end if;
+
+ wait for 0.5 ms;
+
+ if(error_flag = false) then
+ log("Encoder LEDs are OK.", VLOW);
+ end if;
+
+ end if; -- RUN_ENC_TEST
+
+ ---------------------------------------------------------------------------
+ -- End
+ ---------------------------------------------------------------------------
+
+ wait for 20 us;
+
+ passed <= true after 100 ns;
+ wait;
+
+ end process pTEST_PROC;
+
+ failed <= error_flag after 100 ns;
+
+ CHECK_SIM_TIMEOUT: process
+ begin -- process CHECK_SIM_TIMEOUT
+ while now < MAX_SIM_TIME loop
+ wait for 100 us;
+ end loop;
+ test_timeout <= true;
+ wait;
+ end process CHECK_SIM_TIMEOUT;
+
+ pREPORT_RESULT : process
+ begin
+ wait until failed = true or passed = true or test_timeout = true;
+ wait for 1 us;
+ log_separator_line(VLOW);
+ if(failed = true) then
+ log("FAILURE: test completed with errors.", VLOW);
+ elsif(passed = true) then
+ log("SUCCESS: test successfully completed.", VLOW);
+ elsif(test_timeout = true) then
+ log("FAILURE: test achieved max-sim-time without reaching ", VLOW);
+ log(" failed/passed condition.", VLOW);
+ end if;
+ log_separator_line(VLOW);
+ test_completed <= true;
+ end process pREPORT_RESULT;
+
+
+end architecture behav;