From 64ea3e4350aca802eb77bd871409caedcb5bb392 Mon Sep 17 00:00:00 2001 From: James McKenzie Date: Mon, 28 Apr 2025 00:47:12 +0100 Subject: tidy --- spartan6/hp_lcd_driver/.gitignore | 2 +- spartan6/hp_lcd_driver/Makefile | 130 +----------------- spartan6/hp_lcd_driver/Makefile.spartan6 | 129 ++++++++++++++++++ spartan6/hp_lcd_driver/clkgen.vhdl | 73 ---------- spartan6/hp_lcd_driver/clkgen_spartan6.vhdl | 73 ++++++++++ spartan6/hp_lcd_driver/hp_lcd_driver.ucf | 2 +- spartan6/hp_lcd_driver/hp_lcd_driver.vhdl | 36 +---- spartan6/hp_lcd_driver/output_stage.vhdl | 39 +++++- spartan6/hp_lcd_driver/tmds_encode.vhdl | 73 ++++++++++ spartan6/hp_lcd_driver/tmds_output.vhdl | 165 ----------------------- spartan6/hp_lcd_driver/tmds_output_spartan6.vhdl | 121 +++++++++++++++++ 11 files changed, 435 insertions(+), 408 deletions(-) mode change 100644 => 120000 spartan6/hp_lcd_driver/Makefile create mode 100644 spartan6/hp_lcd_driver/Makefile.spartan6 delete mode 100644 spartan6/hp_lcd_driver/clkgen.vhdl create mode 100644 spartan6/hp_lcd_driver/clkgen_spartan6.vhdl create mode 100644 spartan6/hp_lcd_driver/tmds_encode.vhdl delete mode 100644 spartan6/hp_lcd_driver/tmds_output.vhdl create mode 100644 spartan6/hp_lcd_driver/tmds_output_spartan6.vhdl diff --git a/spartan6/hp_lcd_driver/.gitignore b/spartan6/hp_lcd_driver/.gitignore index 567609b..984573f 100644 --- a/spartan6/hp_lcd_driver/.gitignore +++ b/spartan6/hp_lcd_driver/.gitignore @@ -1 +1 @@ -build/ +build_spartan6/ diff --git a/spartan6/hp_lcd_driver/Makefile b/spartan6/hp_lcd_driver/Makefile deleted file mode 100644 index e1beea7..0000000 --- a/spartan6/hp_lcd_driver/Makefile +++ /dev/null @@ -1,129 +0,0 @@ -include relpath.mk - -XILNXD_LICENSE_FILE:=${PWD}/xilinx_ise_vivado_license.lic -export XILINXD_LICENSE_FILE -PART=xc6slx9-2-tqg144 -TOP=hp_lcd_driver -BUILD=build -VSRCS=synchronizer.vhdl debounce.vhdl edge_det.vhdl input_formatter.vhdl input_stage.vhdl output_formatter.vhdl output_analog.vhdl serdes_n_to_1.vhdl tmds_encoder.vhdl tmds_phy.vhdl tmds_output.vhdl output_stage.vhdl clkgen.vhdl hp_lcd_driver.vhdl -UCF=hp_lcd_driver.ucf -UT=hp_lcd_driver.ut -IPSRCS=vram.xco -DESIGN_NAME=${TOP} -DS_HOME=/software/apps/xilinx/ISE/14.7/ISE_DS -ISE_HOME=${DS_HOME}/ISE -ISE_BINDIR_32=${ISE_HOME}/bin/lin -ISE_BINDIR_64=${ISE_HOME}/bin/lin64 -INTSTYLE= - -XST_FLAGS=${INTSTYLE} -NGDBUILD_FLAGS=${INTSTYLE} -p ${PART} -dd _ngo -nt timestamp -MAP_FLAGS=${INTSTYLE} -p ${PART} -w -logic_opt off -ol high -t 1 -xt 0 -register_duplication off -r 4 -global_opt off -mt off -ir off -pr off -lc off -power off -PAR_FLAGS=${INTSTYLE} -w -ol high -mt off -TRCE_FLAGS=${INTSTYLE} -v 3 -s 2 -n 3 -fastpaths -BITGEN_FLAGS=${INTSTYLE} - - - -GEN_VSRCS=${IPSRCS:%.xco=${BUILD}/%.vhd} -BASE=${BUILD}/${DESIGN_NAME} -XST=${BASE}.xst -PRJ=${BASE}.prj -SYR=${BASE}.syr -NGC=${BASE}.ngc -NGD=${BASE}.ngd -MAP_NCD=${BASE}_map.ncd -NCD=${BASE}.ncd -PCF=${BASE}.pcf -TWR=${BASE}.twr -TWX=${BASE}.twx -BIT=${BASE}.bit -SVF=${BASE}.svf -PA=${BUILD}/pa -PAT=${PA}/script.tcl - -XST_TMPDIR=xst/projnav.tmp -XST_DIR=xst - - - -default: ${NCD} ${TWR} ${TWX} ${BIT} ${SVF} - -clean: - /bin/rm -rf ${BUILD} *.orig *~ - -${PRJ}: ${VSRCS} ${GEN_VSRCS} - mkdir -p ${BUILD} - rm -f $@ - for file in $(GEN_VSRCS) ${VSRCS}; do \ - echo "vhdl work $$(realpath -m --relative-to=${BUILD} $${file})" >> $@ ; \ - done ; - -${NGC}:${XST} - (cd ${BUILD} && mkdir -p ${XST_DIR} ${XST_TMPDIR} && ${ISE_BINDIR_64}/xst ${XST_FLAGS} -ifn $(call relpath,$<,${BUILD}) -ofn $(call relpath,${SYR},${BUILD})) - -${XST}: ${PRJ} ${DESIGN_NAME}.xst_template - rm -f $@ - echo 'set -tmpdir "${XST_TMPDIR}"' >> $@ - echo 'set -xsthdpdir "${XST_DIR}"' >> $@ - cat ${DESIGN_NAME}.xst_template >> $@ - echo "-ifn $(call relpath,${PRJ},${BUILD})" >> $@ - echo "-ofn $(call relpath,${BASE},${BUILD})" >> $@ - echo "-p ${PART}" >> $@ - echo "-top ${TOP}" >> $@ - -${NGD}:${NGC} ${UCF} - (cd ${BUILD} && ${ISE_BINDIR_64}/ngdbuild $(NGDBUILD_FLAGS) -uc $(call relpath,${UCF},${BUILD}) $(call relpath,${NGC},${BUILD}) $(call relpath,$@,${BUILD})) - -${MAP_NCD} ${PCF}:${NGD} - (cd ${BUILD} && ${ISE_BINDIR_64}/map $(MAP_FLAGS) -o $(call relpath,${MAP_NCD},${BUILD}) $(call relpath,${NGD},${BUILD}) $(call relpath,${PCF},${BUILD})) - -${NCD}: ${MAP_NCD} ${PCF} - (cd ${BUILD} && ${ISE_BINDIR_64}/par $(PAR_FLAGS) $(call relpath,${MAP_NCD},${BUILD}) $(call relpath,${NCD},${BUILD}) $(call relpath,${PCF},${BUILD})) - -${TWR} ${TWX}: ${NCD} ${PCF} - (cd ${BUILD} && ${ISE_BINDIR_64}/trce ${TRCE_FLAGS} -xml $(call relpath,${TWX},${BUILD}) $(call relpath,${NCD},${BUILD}) -o $(call relpath,${TWR},${BUILD}) $(call relpath,${PCF},${BUILD})) - -${BIT}:${NCD} ${UT} - (cd ${BUILD} && ${ISE_BINDIR_64}/bitgen ${BITGEN_FLAGS} -f $(call relpath,${UT},${BUILD}) $(call relpath,${NCD},${BUILD})) - -${SVF}:${BIT} - ( cd ${BUILD} && \ - echo -e "setMode -bs \n\ - setCable -p svf -file \"$(call relpath,${SVF},${BUILD})\" \n\ - addDevice -p 1 -file \"$(call relpath,${BIT},${BUILD})\" \n\ - program -p 1 \n\ - quit \n" > impact.run &&\ - ${ISE_BINDIR_64}/impact -batch impact.run) - - -${BUILD}/%.vhd:%.xco - mkdir -p ${BUILD} - (cd ${BUILD} && touch empty.prj && ${ISE_BINDIR_32}/coregen -b $(call relpath,$<,${BUILD}) -p empty.prj) - - -planahead: ${NGC} ${TWX} - rm -rf ${PA} - mkdir -p ${PA} - echo 'create_project -name ${TOP} -dir "$(abspath ${PA})" -part ${PART}' >> ${PAT} - echo 'set srcset [get_property srcset [current_run -impl]]' >> ${PAT} - echo 'set_property design_mode GateLvl $$srcset' >> ${PAT} - echo 'set_property top ${TOP} [current_fileset]' >> ${PAT} - echo 'set_property edif_top_file "$(abspasth ${NGC})" [ get_property srcset [ current_run ] ]' >> ${PAT} - echo 'add_files -norecurse { {$(abspath ${BUILD})} }' >> ${PAT} - echo 'set_property target_constrs_file "$(abspath ${UCF})" [current_fileset -constrset]' >> ${PAT} - echo 'add_files [list {$(abspath ${UCF})}] -fileset [get_property constrset [current_run]]' >> ${PAT} - echo 'link_design' >> ${PAT} - echo 'read_xdl -file "$(abspath ${NCD})"' >> ${PAT} - echo 'if {[catch {read_twx -name results_1 -file "$(abspath ${TWX})"} eInfo]} {' >> ${PAT} - echo 'puts "WARNING: there was a problem importing \"$(abspath ${TWX})\": $$eInfo"' >> ${PAT} - echo '}' >> ${PAT} - (cd ${PA} && ${DS_HOME}/PlanAhead/bin/planAhead -log $(abspath ${PA}/pa.log) -journal $(abspath ${PA}/pa.jou) -source $(abspath ${PAT})) - - - -tidy: - git diff --exit-code -s ${VSRCS} - for i in ${VSRCS}; do /bin/cp -f $$i $$i.orig && scripts/vhdl-pretty < $$i.orig > $$i; done - - diff --git a/spartan6/hp_lcd_driver/Makefile b/spartan6/hp_lcd_driver/Makefile new file mode 120000 index 0000000..b3e7186 --- /dev/null +++ b/spartan6/hp_lcd_driver/Makefile @@ -0,0 +1 @@ +Makefile.spartan6 \ No newline at end of file diff --git a/spartan6/hp_lcd_driver/Makefile.spartan6 b/spartan6/hp_lcd_driver/Makefile.spartan6 new file mode 100644 index 0000000..83a389e --- /dev/null +++ b/spartan6/hp_lcd_driver/Makefile.spartan6 @@ -0,0 +1,129 @@ +include relpath.mk + +XILNXD_LICENSE_FILE:=${PWD}/xilinx_ise_vivado_license.lic +export XILINXD_LICENSE_FILE +PART=xc6slx9-2-tqg144 +TOP=hp_lcd_driver +BUILD=build_spartan6 +VSRCS=synchronizer.vhdl debounce.vhdl edge_det.vhdl input_formatter.vhdl input_stage.vhdl output_formatter.vhdl output_analog.vhdl serdes_n_to_1.vhdl tmds_encoder.vhdl tmds_phy.vhdl tmds_encode.vhdl tmds_output_spartan6.vhdl output_stage.vhdl clkgen_spartan6.vhdl hp_lcd_driver.vhdl +UCF=hp_lcd_driver.ucf +UT=hp_lcd_driver.ut +IPSRCS=vram.xco +DESIGN_NAME=${TOP} +DS_HOME=/software/apps/xilinx/ISE/14.7/ISE_DS +ISE_HOME=${DS_HOME}/ISE +ISE_BINDIR_32=${ISE_HOME}/bin/lin +ISE_BINDIR_64=${ISE_HOME}/bin/lin64 +INTSTYLE= + +XST_FLAGS=${INTSTYLE} +NGDBUILD_FLAGS=${INTSTYLE} -p ${PART} -dd _ngo -nt timestamp +MAP_FLAGS=${INTSTYLE} -p ${PART} -w -logic_opt off -ol high -t 1 -xt 0 -register_duplication off -r 4 -global_opt off -mt off -ir off -pr off -lc off -power off +PAR_FLAGS=${INTSTYLE} -w -ol high -mt off +TRCE_FLAGS=${INTSTYLE} -v 3 -s 2 -n 3 -fastpaths +BITGEN_FLAGS=${INTSTYLE} + + + +GEN_VSRCS=${IPSRCS:%.xco=${BUILD}/%.vhd} +BASE=${BUILD}/${DESIGN_NAME} +XST=${BASE}.xst +PRJ=${BASE}.prj +SYR=${BASE}.syr +NGC=${BASE}.ngc +NGD=${BASE}.ngd +MAP_NCD=${BASE}_map.ncd +NCD=${BASE}.ncd +PCF=${BASE}.pcf +TWR=${BASE}.twr +TWX=${BASE}.twx +BIT=${BASE}.bit +SVF=${BASE}.svf +PA=${BUILD}/pa +PAT=${PA}/script.tcl + +XST_TMPDIR=xst/projnav.tmp +XST_DIR=xst + + + +default: ${NCD} ${TWR} ${TWX} ${BIT} ${SVF} + +clean: + /bin/rm -rf ${BUILD} *.orig *~ + +${PRJ}: ${VSRCS} ${GEN_VSRCS} + mkdir -p ${BUILD} + rm -f $@ + for file in $(GEN_VSRCS) ${VSRCS}; do \ + echo "vhdl work $$(realpath -m --relative-to=${BUILD} $${file})" >> $@ ; \ + done ; + +${NGC}:${XST} + (cd ${BUILD} && mkdir -p ${XST_DIR} ${XST_TMPDIR} && ${ISE_BINDIR_64}/xst ${XST_FLAGS} -ifn $(call relpath,$<,${BUILD}) -ofn $(call relpath,${SYR},${BUILD})) + +${XST}: ${PRJ} ${DESIGN_NAME}.xst_template + rm -f $@ + echo 'set -tmpdir "${XST_TMPDIR}"' >> $@ + echo 'set -xsthdpdir "${XST_DIR}"' >> $@ + cat ${DESIGN_NAME}.xst_template >> $@ + echo "-ifn $(call relpath,${PRJ},${BUILD})" >> $@ + echo "-ofn $(call relpath,${BASE},${BUILD})" >> $@ + echo "-p ${PART}" >> $@ + echo "-top ${TOP}" >> $@ + +${NGD}:${NGC} ${UCF} + (cd ${BUILD} && ${ISE_BINDIR_64}/ngdbuild $(NGDBUILD_FLAGS) -uc $(call relpath,${UCF},${BUILD}) $(call relpath,${NGC},${BUILD}) $(call relpath,$@,${BUILD})) + +${MAP_NCD} ${PCF}:${NGD} + (cd ${BUILD} && ${ISE_BINDIR_64}/map $(MAP_FLAGS) -o $(call relpath,${MAP_NCD},${BUILD}) $(call relpath,${NGD},${BUILD}) $(call relpath,${PCF},${BUILD})) + +${NCD}: ${MAP_NCD} ${PCF} + (cd ${BUILD} && ${ISE_BINDIR_64}/par $(PAR_FLAGS) $(call relpath,${MAP_NCD},${BUILD}) $(call relpath,${NCD},${BUILD}) $(call relpath,${PCF},${BUILD})) + +${TWR} ${TWX}: ${NCD} ${PCF} + (cd ${BUILD} && ${ISE_BINDIR_64}/trce ${TRCE_FLAGS} -xml $(call relpath,${TWX},${BUILD}) $(call relpath,${NCD},${BUILD}) -o $(call relpath,${TWR},${BUILD}) $(call relpath,${PCF},${BUILD})) + +${BIT}:${NCD} ${UT} + (cd ${BUILD} && ${ISE_BINDIR_64}/bitgen ${BITGEN_FLAGS} -f $(call relpath,${UT},${BUILD}) $(call relpath,${NCD},${BUILD})) + +${SVF}:${BIT} + ( cd ${BUILD} && \ + echo -e "setMode -bs \n\ + setCable -p svf -file \"$(call relpath,${SVF},${BUILD})\" \n\ + addDevice -p 1 -file \"$(call relpath,${BIT},${BUILD})\" \n\ + program -p 1 \n\ + quit \n" > impact.run &&\ + ${ISE_BINDIR_64}/impact -batch impact.run) + + +${BUILD}/%.vhd:%.xco + mkdir -p ${BUILD} + (cd ${BUILD} && touch empty.prj && ${ISE_BINDIR_32}/coregen -b $(call relpath,$<,${BUILD}) -p empty.prj) + + +planahead: ${NGC} ${TWX} + rm -rf ${PA} + mkdir -p ${PA} + echo 'create_project -name ${TOP} -dir "$(abspath ${PA})" -part ${PART}' >> ${PAT} + echo 'set srcset [get_property srcset [current_run -impl]]' >> ${PAT} + echo 'set_property design_mode GateLvl $$srcset' >> ${PAT} + echo 'set_property top ${TOP} [current_fileset]' >> ${PAT} + echo 'set_property edif_top_file "$(abspasth ${NGC})" [ get_property srcset [ current_run ] ]' >> ${PAT} + echo 'add_files -norecurse { {$(abspath ${BUILD})} }' >> ${PAT} + echo 'set_property target_constrs_file "$(abspath ${UCF})" [current_fileset -constrset]' >> ${PAT} + echo 'add_files [list {$(abspath ${UCF})}] -fileset [get_property constrset [current_run]]' >> ${PAT} + echo 'link_design' >> ${PAT} + echo 'read_xdl -file "$(abspath ${NCD})"' >> ${PAT} + echo 'if {[catch {read_twx -name results_1 -file "$(abspath ${TWX})"} eInfo]} {' >> ${PAT} + echo 'puts "WARNING: there was a problem importing \"$(abspath ${TWX})\": $$eInfo"' >> ${PAT} + echo '}' >> ${PAT} + (cd ${PA} && ${DS_HOME}/PlanAhead/bin/planAhead -log $(abspath ${PA}/pa.log) -journal $(abspath ${PA}/pa.jou) -source $(abspath ${PAT})) + + + +tidy: + git diff --exit-code -s ${VSRCS} + for i in ${VSRCS}; do /bin/cp -f $$i $$i.orig && scripts/vhdl-pretty < $$i.orig > $$i; done + + diff --git a/spartan6/hp_lcd_driver/clkgen.vhdl b/spartan6/hp_lcd_driver/clkgen.vhdl deleted file mode 100644 index 5d3c8f2..0000000 --- a/spartan6/hp_lcd_driver/clkgen.vhdl +++ /dev/null @@ -1,73 +0,0 @@ -library IEEE; -use IEEE.STD_LOGIC_1164.all; -use IEEE.NUMERIC_STD.all; -use work.all; - -library UNISIM; -use UNISIM.vcomponents.all; - -entity clkgen is - port ( - sys_rst_n:in std_logic; - clk_in: in std_logic; - i_clk:out std_logic; - o_clk:out std_logic; - o_clk_x2: out std_logic; - o_clk_x10: out std_logic; - locked: out std_logic - ); -end clkgen; -architecture Behavioural of clkgen is - - signal clkfbout : std_logic; - signal clk_200m : std_logic; - signal clk_80m : std_logic; - signal clk_40m : std_logic; - signal clk_20m : std_logic; - signal pll_locked : std_logic; - - signal reset : std_logic; -begin - - pll : PLL_BASE generic map ( - CLKIN_PERIOD => 20.0, - CLKFBOUT_MULT => 8, - CLKOUT0_DIVIDE => 2, - CLKOUT1_DIVIDE => 5, - CLKOUT2_DIVIDE => 10, - CLKOUT3_DIVIDE => 20, - COMPENSATION => "INTERNAL") - port map ( - CLKFBOUT => clkfbout, - CLKOUT0 => clk_200m, - CLKOUT1 => clk_80m, - CLKOUT2 => clk_40m, - CLKOUT3 => clk_20m, - LOCKED => pll_locked, - CLKFBIN => clkfbout, - CLKIN => clk_in, - RST => reset); - - reset <= (not pll_locked) or (not sys_rst_n); - - - - o_clk_buf : BUFG port map ( - I =>clk_20m, - O =>o_clk); - - - o_clk_x2_buf : BUFG port map ( - I =>clk_40m, - O =>o_clk_x2); - - - i_clk_buf : BUFG port map ( - I =>clk_80m, - O =>i_clk); - - o_clk_x10 <= clk_200m; - - locked <= pll_locked; - -end Behavioural; diff --git a/spartan6/hp_lcd_driver/clkgen_spartan6.vhdl b/spartan6/hp_lcd_driver/clkgen_spartan6.vhdl new file mode 100644 index 0000000..e3c0242 --- /dev/null +++ b/spartan6/hp_lcd_driver/clkgen_spartan6.vhdl @@ -0,0 +1,73 @@ +library IEEE; +use IEEE.STD_LOGIC_1164.all; +use IEEE.NUMERIC_STD.all; +use work.all; + +library UNISIM; +use UNISIM.vcomponents.all; + +entity clkgen_spartan6 is + port ( + sys_rst_n:in std_logic; + clk_in: in std_logic; + i_clk:out std_logic; + o_clk:out std_logic; + o_clk_x2: out std_logic; + o_clk_x10: out std_logic; + locked: out std_logic + ); +end clkgen_spartan6; +architecture Behavioural of clkgen_spartan6 is + + signal clkfbout : std_logic; + signal clk_200m : std_logic; + signal clk_80m : std_logic; + signal clk_40m : std_logic; + signal clk_20m : std_logic; + signal pll_locked : std_logic; + + signal reset : std_logic; +begin + + pll : PLL_BASE generic map ( + CLKIN_PERIOD => 20.0, + CLKFBOUT_MULT => 8, + CLKOUT0_DIVIDE => 2, + CLKOUT1_DIVIDE => 5, + CLKOUT2_DIVIDE => 10, + CLKOUT3_DIVIDE => 20, + COMPENSATION => "INTERNAL") + port map ( + CLKFBOUT => clkfbout, + CLKOUT0 => clk_200m, + CLKOUT1 => clk_80m, + CLKOUT2 => clk_40m, + CLKOUT3 => clk_20m, + LOCKED => pll_locked, + CLKFBIN => clkfbout, + CLKIN => clk_in, + RST => reset); + + reset <= (not pll_locked) or (not sys_rst_n); + + + + o_clk_buf : BUFG port map ( + I =>clk_20m, + O =>o_clk); + + + o_clk_x2_buf : BUFG port map ( + I =>clk_40m, + O =>o_clk_x2); + + + i_clk_buf : BUFG port map ( + I =>clk_80m, + O =>i_clk); + + o_clk_x10 <= clk_200m; + + locked <= pll_locked; + +end Behavioural; diff --git a/spartan6/hp_lcd_driver/hp_lcd_driver.ucf b/spartan6/hp_lcd_driver/hp_lcd_driver.ucf index c30e6e3..ae00a1b 100644 --- a/spartan6/hp_lcd_driver/hp_lcd_driver.ucf +++ b/spartan6/hp_lcd_driver/hp_lcd_driver.ucf @@ -15,7 +15,7 @@ NET "vsync_out" IOSTANDARD = LVCMOS33; INST "clkgen/pll" LOC = PLL_ADV_X0Y1; -INST "output0/tmds/ioclk_buf" LOC = BUFPLL_X1Y5; +INST "output0/tmds_o/ioclk_buf" LOC = BUFPLL_X1Y5; NET "hdmi_c_p" LOC = P144; NET "hdmi_c_n" LOC = P143; diff --git a/spartan6/hp_lcd_driver/hp_lcd_driver.vhdl b/spartan6/hp_lcd_driver/hp_lcd_driver.vhdl index d37db58..0337320 100644 --- a/spartan6/hp_lcd_driver/hp_lcd_driver.vhdl +++ b/spartan6/hp_lcd_driver/hp_lcd_driver.vhdl @@ -1,41 +1,12 @@ ----------------------------------------------------------------------------------- --- Company: --- Engineer: --- --- Create Date: 13:20:32 04/26/2025 --- Design Name: --- Module Name: hp_lcd_driver - Behavioral --- Project Name: --- Target Devices: --- Tool versions: --- Description: --- --- Dependencies: --- --- Revision: --- Revision 0.01 - File Created --- Additional Comments: --- ----------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.NUMERIC_STD.all; use work.all; -library UNISIM; -use UNISIM.vcomponents.all; - --- Uncomment the following library declaration if using --- arithmetic functions with Signed or Unsigned values - --- Uncomment the following library declaration if instantiating --- any Xilinx primitives in this code. ---library UNISIM; ---use UNISIM.VComponents.all; - entity hp_lcd_driver is generic (video_width : natural := 2; - addr_width : natural := 18); + addr_width : natural := 18; + target : string := "spartan6" ); port (clk_50m : in std_logic; sys_rst_n : in std_logic; video : in std_logic_vector(video_width-1 downto 0); @@ -84,7 +55,7 @@ architecture Behavioral of hp_lcd_driver is begin - clkgen: entity work.clkgen + clkgen: entity work.clkgen_spartan6 port map ( sys_rst_n => sys_rst_n, clk_in => clk_50m, @@ -146,6 +117,7 @@ begin -- works at 60Hz xrandr --newmode "$M" 18.24 384 400 440 600 592 593 596 613 -HSync +Vsync generic map ( + target => target, addr_width => addr_width, h_active => 384, h_sync_start => 400, diff --git a/spartan6/hp_lcd_driver/output_stage.vhdl b/spartan6/hp_lcd_driver/output_stage.vhdl index 0b04de0..0c75b3d 100644 --- a/spartan6/hp_lcd_driver/output_stage.vhdl +++ b/spartan6/hp_lcd_driver/output_stage.vhdl @@ -7,7 +7,8 @@ use UNISIM.vcomponents.all; entity output_stage is - generic (debounce_stages : natural := 2; + generic (target : string := "spartan6"; + debounce_stages : natural := 2; sync_stages : natural := 2; addr_width : natural := 17; h_front_porch : natural := 208; @@ -70,6 +71,13 @@ architecture beh of output_stage is signal addr : std_logic_vector(addr_width - 1 downto 0); + + signal r_p10 :std_logic_vector(9 downto 0); + signal g_p10 :std_logic_vector(9 downto 0); + signal b_p10 :std_logic_vector(9 downto 0); + signal c_p10 :std_logic_vector(9 downto 0); + + begin @@ -137,14 +145,9 @@ begin ); - - tmds : entity work.tmds_output - port map ( +tmds_e : entity work.tmds_encode port map ( sys_rst_n => sys_rst_n, - pclk_locked => clk_locked, pclk => clk, - pclk_x2 => clk_x2, - pclk_x10 => clk_x10, r_in => r_in, g_in => g_in, @@ -153,6 +156,28 @@ begin vsync => vsync, blank => blank, + r_p10 => r_p10, + g_p10 => g_p10, + b_p10 => b_p10, + c_p10 => c_p10 + + ); + + + + tmds_o : entity work.tmds_output_spartan6 + port map ( + sys_rst_n => sys_rst_n, + pclk_locked => clk_locked, + pclk => clk, + pclk_x2 => clk_x2, + pclk_x10 => clk_x10, + + r_p10 => r_p10, + g_p10 => g_p10, + b_p10 => b_p10, + c_p10 => c_p10, + tmds_c_out_p => hdmi_c_p, tmds_c_out_n => hdmi_c_n, tmds_r_out_p => hdmi_r_p, diff --git a/spartan6/hp_lcd_driver/tmds_encode.vhdl b/spartan6/hp_lcd_driver/tmds_encode.vhdl new file mode 100644 index 0000000..d302960 --- /dev/null +++ b/spartan6/hp_lcd_driver/tmds_encode.vhdl @@ -0,0 +1,73 @@ +library ieee; +use ieee.std_logic_1164.all; +use IEEE.NUMERIC_STD.all; + + +entity tmds_encode is + port ( + sys_rst_n : in std_logic; + pclk : in std_logic; + + r_in : in std_logic_vector(7 downto 0); + g_in : in std_logic_vector(7 downto 0); + b_in : in std_logic_vector(7 downto 0); + hsync : in std_logic; + vsync : in std_logic; + blank : in std_logic; + + + r_p10 : out std_logic_vector(9 downto 0); + g_p10 : out std_logic_vector(9 downto 0); + b_p10 : out std_logic_vector(9 downto 0); + c_p10 : out std_logic_vector(9 downto 0) + + ); +end tmds_encode; + + +architecture beh of tmds_encode is + signal ctrl : std_logic_vector(1 downto 0); + +begin + +c_p10 <= "1111100000"; + + ctrl <= vsync & hsync; + + + enc_r : entity work.tmds_encoder + port map ( + sys_rst_n => sys_rst_n, + clk => pclk, + ctrl => ctrl, + blank => blank, + din => r_in, + dout => r_p10 + ); + + enc_g : entity work.tmds_encoder + port map ( + sys_rst_n => sys_rst_n, + clk => pclk, + ctrl => "11", + blank => blank, + din => g_in, + dout => g_p10 + ); + + + + enc_b : entity work.tmds_encoder + port map ( + sys_rst_n => sys_rst_n, + clk => pclk, + ctrl => "11", + blank => blank, + din => b_in, + dout => b_p10 + ); + + +end beh; + + diff --git a/spartan6/hp_lcd_driver/tmds_output.vhdl b/spartan6/hp_lcd_driver/tmds_output.vhdl deleted file mode 100644 index ba095ef..0000000 --- a/spartan6/hp_lcd_driver/tmds_output.vhdl +++ /dev/null @@ -1,165 +0,0 @@ -library ieee; -use ieee.std_logic_1164.all; -use IEEE.NUMERIC_STD.all; - -library UNISIM; -use UNISIM.vcomponents.all; - - -entity tmds_output is - port ( - sys_rst_n : in std_logic; - pclk_locked : in std_logic; - pclk : in std_logic; - pclk_x2 : in std_logic; - pclk_x10 : in std_logic; - r_in : in std_logic_vector(7 downto 0); - g_in : in std_logic_vector(7 downto 0); - b_in : in std_logic_vector(7 downto 0); - hsync : in std_logic; - vsync : in std_logic; - blank : in std_logic; - tmds_c_out_p : out std_logic; - tmds_c_out_n : out std_logic; - tmds_r_out_p : out std_logic; - tmds_r_out_n : out std_logic; - tmds_g_out_p : out std_logic; - tmds_g_out_n : out std_logic; - tmds_b_out_p : out std_logic; - tmds_b_out_n : out std_logic - ); -end tmds_output; - - -architecture beh of tmds_output is - - signal ctrl : std_logic_vector(1 downto 0); - signal r_p10 : std_logic_vector(9 downto 0); - signal g_p10 : std_logic_vector(9 downto 0); - signal b_p10 : std_logic_vector(9 downto 0); - - signal phy_reset : std_logic; - signal upper : std_logic; - signal pll_locked: std_logic; - signal ioclk: std_logic; - signal serdesstrobe : std_logic; - -begin - - - ctrl <= vsync & hsync; - - - - - enc_r : entity work.tmds_encoder - port map ( - sys_rst_n => sys_rst_n, - clk => pclk, - ctrl => ctrl, - blank => blank, - din => r_in, - dout => r_p10 - ); - - - enc_g : entity work.tmds_encoder - port map ( - sys_rst_n => sys_rst_n, - clk => pclk, - ctrl => "11", - blank => blank, - din => g_in, - dout => g_p10 - ); - - - - enc_b : entity work.tmds_encoder - port map ( - sys_rst_n => sys_rst_n, - clk => pclk, - ctrl => "11", - blank => blank, - din => b_in, - dout => b_p10 - ); - - - phy_reset <= not sys_rst_n or not pll_locked; - - process (pclk_x2,phy_reset) - begin - if phy_reset = '1' then - upper <= '1'; - elsif rising_edge(pclk_x2) then - upper <= not upper; - end if; - end process; - - - ioclk_buf : BUFPLL generic map (DIVIDE => 5) - port map ( - PLLIN => pclk_x10, - GCLK => pclk_x2, - LOCKED => pclk_locked, - IOCLK => ioclk, - SERDESSTROBE => serdesstrobe, - LOCK => pll_locked); - - - phy_c : entity work.tmds_phy - port map ( - reset => phy_reset, - pclk_x2 => pclk_x2, - serdesstrobe => serdesstrobe, - ioclk => ioclk, - upper => upper, - din => "1111100000", - tmds_out_p => tmds_c_out_p, - tmds_out_n => tmds_c_out_n - ); - - phy_r : entity work.tmds_phy - port map ( - reset => phy_reset, - pclk_x2 => pclk_x2, - serdesstrobe => serdesstrobe, - ioclk => ioclk, - upper => upper, - din => r_p10, - tmds_out_p => tmds_r_out_p, - tmds_out_n => tmds_r_out_n - ); - - - phy_g : entity work.tmds_phy - port map ( - reset => phy_reset, - pclk_x2 => pclk_x2, - serdesstrobe => serdesstrobe, - ioclk => ioclk, - upper => upper, - din => g_p10, - tmds_out_p => tmds_g_out_p, - tmds_out_n => tmds_g_out_n - ); - - - phy_b : entity work.tmds_phy - port map ( - reset => phy_reset, - pclk_x2 => pclk_x2, - serdesstrobe => serdesstrobe, - ioclk => pclk_x10, - upper => upper, - din => b_p10, - tmds_out_p => tmds_b_out_p, - tmds_out_n => tmds_b_out_n - ); - - - - - -end beh; diff --git a/spartan6/hp_lcd_driver/tmds_output_spartan6.vhdl b/spartan6/hp_lcd_driver/tmds_output_spartan6.vhdl new file mode 100644 index 0000000..3212998 --- /dev/null +++ b/spartan6/hp_lcd_driver/tmds_output_spartan6.vhdl @@ -0,0 +1,121 @@ +library ieee; +use ieee.std_logic_1164.all; +use IEEE.NUMERIC_STD.all; + +library UNISIM; +use UNISIM.vcomponents.all; + + +entity tmds_output_spartan6 is + port ( + sys_rst_n : in std_logic; + pclk_locked : in std_logic; + pclk : in std_logic; + pclk_x2 : in std_logic; + pclk_x10 : in std_logic; + + r_p10 : in std_logic_vector(9 downto 0); + g_p10 : in std_logic_vector(9 downto 0); + b_p10 : in std_logic_vector(9 downto 0); + c_p10 : in std_logic_vector(9 downto 0); + + + tmds_c_out_p : out std_logic; + tmds_c_out_n : out std_logic; + tmds_r_out_p : out std_logic; + tmds_r_out_n : out std_logic; + tmds_g_out_p : out std_logic; + tmds_g_out_n : out std_logic; + tmds_b_out_p : out std_logic; + tmds_b_out_n : out std_logic + ); +end tmds_output_spartan6; + + +architecture beh of tmds_output_spartan6 is + + + signal phy_reset : std_logic; + signal upper : std_logic; + signal pll_locked: std_logic; + signal ioclk: std_logic; + signal serdesstrobe : std_logic; + +begin + phy_reset <= not sys_rst_n or not pll_locked; + + process (pclk_x2,phy_reset) + begin + if phy_reset = '1' then + upper <= '1'; + elsif rising_edge(pclk_x2) then + upper <= not upper; + end if; + end process; + + + ioclk_buf : BUFPLL generic map (DIVIDE => 5) + port map ( + PLLIN => pclk_x10, + GCLK => pclk_x2, + LOCKED => pclk_locked, + IOCLK => ioclk, + SERDESSTROBE => serdesstrobe, + LOCK => pll_locked); + + + phy_c : entity work.tmds_phy + port map ( + reset => phy_reset, + pclk_x2 => pclk_x2, + serdesstrobe => serdesstrobe, + ioclk => ioclk, + upper => upper, + din => c_p10, + tmds_out_p => tmds_c_out_p, + tmds_out_n => tmds_c_out_n + ); + + phy_r : entity work.tmds_phy + port map ( + reset => phy_reset, + pclk_x2 => pclk_x2, + serdesstrobe => serdesstrobe, + ioclk => ioclk, + upper => upper, + din => r_p10, + tmds_out_p => tmds_r_out_p, + tmds_out_n => tmds_r_out_n + ); + + + phy_g : entity work.tmds_phy + port map ( + reset => phy_reset, + pclk_x2 => pclk_x2, + serdesstrobe => serdesstrobe, + ioclk => ioclk, + upper => upper, + din => g_p10, + tmds_out_p => tmds_g_out_p, + tmds_out_n => tmds_g_out_n + ); + + + phy_b : entity work.tmds_phy + port map ( + reset => phy_reset, + pclk_x2 => pclk_x2, + serdesstrobe => serdesstrobe, + ioclk => pclk_x10, + upper => upper, + din => b_p10, + tmds_out_p => tmds_b_out_p, + tmds_out_n => tmds_b_out_n + ); + + + + + +end beh; -- cgit v1.2.3