diff --git a/.gitignore b/.gitignore
index 7747d92..299f53b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@
*.wdf
*.lpr
*.bxml
+*.zip
# Vivado project directories
diff --git a/LAB3/design/lab_3/lab_3.bd b/LAB3/design/lab_3/lab_3.bd
index 310fa5a..9b22386 100644
--- a/LAB3/design/lab_3/lab_3.bd
+++ b/LAB3/design/lab_3/lab_3.bd
@@ -18,7 +18,6 @@
"axis_broadcaster_0": "",
"moving_average_filte_0": "",
"volume_controller_0": "",
- "LFO_0": "",
"balance_controller_0": "",
"effect_selector_0": "",
"led_controller_0": "",
@@ -26,7 +25,8 @@
"mute_controller_0": "",
"axi4stream_spi_master_0": "",
"axis_dual_i2s_0": "",
- "digilent_jstk2_0": ""
+ "digilent_jstk2_0": "",
+ "LFO_0": ""
},
"interface_ports": {
"SPI_M_0": {
@@ -720,210 +720,6 @@
}
}
},
- "LFO_0": {
- "vlnv": "xilinx.com:module_ref:LFO:1.0",
- "xci_name": "lab_3_LFO_0_0",
- "xci_path": "ip\\lab_3_LFO_0_0\\lab_3_LFO_0_0.xci",
- "inst_hier_path": "LFO_0",
- "parameters": {
- "CLK_PERIOD_NS": {
- "value": "10"
- }
- },
- "reference_info": {
- "ref_type": "hdl",
- "ref_name": "LFO",
- "boundary_crc": "0x0"
- },
- "interface_ports": {
- "m_axis": {
- "mode": "Master",
- "vlnv": "xilinx.com:interface:axis_rtl:1.0",
- "parameters": {
- "TDATA_NUM_BYTES": {
- "value": "3",
- "value_src": "auto"
- },
- "TDEST_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "TID_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "TUSER_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TREADY": {
- "value": "1",
- "value_src": "constant"
- },
- "HAS_TSTRB": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TKEEP": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TLAST": {
- "value": "1",
- "value_src": "constant"
- },
- "FREQ_HZ": {
- "value": "100000000",
- "value_src": "ip_prop"
- },
- "PHASE": {
- "value": "0.0",
- "value_src": "ip_prop"
- },
- "CLK_DOMAIN": {
- "value": "/clk_wiz_0_clk_out1",
- "value_src": "ip_prop"
- }
- },
- "port_maps": {
- "TDATA": {
- "physical_name": "m_axis_tdata",
- "direction": "O",
- "left": "23",
- "right": "0"
- },
- "TLAST": {
- "physical_name": "m_axis_tlast",
- "direction": "O"
- },
- "TVALID": {
- "physical_name": "m_axis_tvalid",
- "direction": "O"
- },
- "TREADY": {
- "physical_name": "m_axis_tready",
- "direction": "I"
- }
- }
- },
- "s_axis": {
- "mode": "Slave",
- "vlnv": "xilinx.com:interface:axis_rtl:1.0",
- "parameters": {
- "TDATA_NUM_BYTES": {
- "value": "3",
- "value_src": "auto"
- },
- "TDEST_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "TID_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "TUSER_WIDTH": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TREADY": {
- "value": "1",
- "value_src": "constant"
- },
- "HAS_TSTRB": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TKEEP": {
- "value": "0",
- "value_src": "constant"
- },
- "HAS_TLAST": {
- "value": "1",
- "value_src": "constant"
- },
- "FREQ_HZ": {
- "value": "100000000",
- "value_src": "ip_prop"
- },
- "PHASE": {
- "value": "0.0",
- "value_src": "ip_prop"
- },
- "CLK_DOMAIN": {
- "value": "/clk_wiz_0_clk_out1",
- "value_src": "ip_prop"
- }
- },
- "port_maps": {
- "TDATA": {
- "physical_name": "s_axis_tdata",
- "direction": "I",
- "left": "23",
- "right": "0"
- },
- "TLAST": {
- "physical_name": "s_axis_tlast",
- "direction": "I"
- },
- "TVALID": {
- "physical_name": "s_axis_tvalid",
- "direction": "I"
- },
- "TREADY": {
- "physical_name": "s_axis_tready",
- "direction": "O"
- }
- }
- }
- },
- "ports": {
- "aclk": {
- "type": "clk",
- "direction": "I",
- "parameters": {
- "ASSOCIATED_BUSIF": {
- "value": "m_axis:s_axis",
- "value_src": "constant"
- },
- "ASSOCIATED_RESET": {
- "value": "aresetn",
- "value_src": "constant"
- },
- "FREQ_HZ": {
- "value": "100000000",
- "value_src": "ip_prop"
- },
- "PHASE": {
- "value": "0.0",
- "value_src": "ip_prop"
- },
- "CLK_DOMAIN": {
- "value": "/clk_wiz_0_clk_out1",
- "value_src": "ip_prop"
- }
- }
- },
- "aresetn": {
- "type": "rst",
- "direction": "I",
- "parameters": {
- "POLARITY": {
- "value": "ACTIVE_LOW",
- "value_src": "constant"
- }
- }
- },
- "lfo_period": {
- "direction": "I",
- "left": "9",
- "right": "0"
- },
- "lfo_enable": {
- "direction": "I"
- }
- }
- },
"balance_controller_0": {
"vlnv": "xilinx.com:module_ref:balance_controller:1.0",
"xci_name": "lab_3_balance_controller_0_0",
@@ -1750,19 +1546,181 @@
"right": "0"
}
}
+ },
+ "LFO_0": {
+ "vlnv": "xilinx.com:module_ref:LFO:1.0",
+ "xci_name": "lab_3_LFO_0_0",
+ "xci_path": "ip\\lab_3_LFO_0_0\\lab_3_LFO_0_0.xci",
+ "inst_hier_path": "LFO_0",
+ "parameters": {
+ "CLK_PERIOD_NS": {
+ "value": "10"
+ }
+ },
+ "reference_info": {
+ "ref_type": "hdl",
+ "ref_name": "LFO",
+ "boundary_crc": "0x0"
+ },
+ "interface_ports": {
+ "m_axis": {
+ "mode": "Master",
+ "vlnv": "xilinx.com:interface:axis_rtl:1.0",
+ "parameters": {
+ "TDATA_NUM_BYTES": {
+ "value": "3",
+ "value_src": "auto"
+ },
+ "TDEST_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "TID_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "TUSER_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TREADY": {
+ "value": "1",
+ "value_src": "constant"
+ },
+ "HAS_TSTRB": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TKEEP": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TLAST": {
+ "value": "1",
+ "value_src": "constant"
+ }
+ },
+ "port_maps": {
+ "TDATA": {
+ "physical_name": "m_axis_tdata",
+ "direction": "O",
+ "left": "23",
+ "right": "0"
+ },
+ "TLAST": {
+ "physical_name": "m_axis_tlast",
+ "direction": "O"
+ },
+ "TVALID": {
+ "physical_name": "m_axis_tvalid",
+ "direction": "O"
+ },
+ "TREADY": {
+ "physical_name": "m_axis_tready",
+ "direction": "I"
+ }
+ }
+ },
+ "s_axis": {
+ "mode": "Slave",
+ "vlnv": "xilinx.com:interface:axis_rtl:1.0",
+ "parameters": {
+ "TDATA_NUM_BYTES": {
+ "value": "3",
+ "value_src": "auto"
+ },
+ "TDEST_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "TID_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "TUSER_WIDTH": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TREADY": {
+ "value": "1",
+ "value_src": "constant"
+ },
+ "HAS_TSTRB": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TKEEP": {
+ "value": "0",
+ "value_src": "constant"
+ },
+ "HAS_TLAST": {
+ "value": "1",
+ "value_src": "constant"
+ }
+ },
+ "port_maps": {
+ "TDATA": {
+ "physical_name": "s_axis_tdata",
+ "direction": "I",
+ "left": "23",
+ "right": "0"
+ },
+ "TLAST": {
+ "physical_name": "s_axis_tlast",
+ "direction": "I"
+ },
+ "TVALID": {
+ "physical_name": "s_axis_tvalid",
+ "direction": "I"
+ },
+ "TREADY": {
+ "physical_name": "s_axis_tready",
+ "direction": "O"
+ }
+ }
+ }
+ },
+ "ports": {
+ "aclk": {
+ "type": "clk",
+ "direction": "I",
+ "parameters": {
+ "ASSOCIATED_BUSIF": {
+ "value": "m_axis:s_axis",
+ "value_src": "constant"
+ },
+ "ASSOCIATED_RESET": {
+ "value": "aresetn",
+ "value_src": "constant"
+ }
+ }
+ },
+ "aresetn": {
+ "type": "rst",
+ "direction": "I",
+ "parameters": {
+ "POLARITY": {
+ "value": "ACTIVE_LOW",
+ "value_src": "constant"
+ }
+ }
+ },
+ "lfo_period": {
+ "direction": "I",
+ "left": "9",
+ "right": "0"
+ },
+ "lfo_enable": {
+ "direction": "I"
+ }
+ }
}
},
"interface_nets": {
- "axis_dual_i2s_0_m_axis": {
+ "axi4stream_spi_master_0_M_AXIS": {
"interface_ports": [
- "axis_dual_i2s_0/m_axis",
- "moving_average_filte_0/s_axis"
- ]
- },
- "LFO_0_m_axis": {
- "interface_ports": [
- "LFO_0/m_axis",
- "mute_controller_0/s_axis"
+ "axi4stream_spi_master_0/M_AXIS",
+ "digilent_jstk2_0/s_axis"
]
},
"digilent_jstk2_0_m_axis": {
@@ -1777,6 +1735,18 @@
"axi4stream_spi_master_0/SPI_M"
]
},
+ "axis_broadcaster_0_M01_AXIS": {
+ "interface_ports": [
+ "axis_broadcaster_0/M01_AXIS",
+ "led_level_controller_0/s_axis"
+ ]
+ },
+ "LFO_0_m_axis": {
+ "interface_ports": [
+ "LFO_0/m_axis",
+ "mute_controller_0/s_axis"
+ ]
+ },
"volume_controller_0_m_axis": {
"interface_ports": [
"volume_controller_0/m_axis",
@@ -1789,28 +1759,16 @@
"axis_dual_i2s_0/s_axis"
]
},
- "axi4stream_spi_master_0_M_AXIS": {
- "interface_ports": [
- "axi4stream_spi_master_0/M_AXIS",
- "digilent_jstk2_0/s_axis"
- ]
- },
"balance_controller_0_m_axis": {
"interface_ports": [
"balance_controller_0/m_axis",
"volume_controller_0/s_axis"
]
},
- "mute_controller_0_m_axis": {
+ "axis_dual_i2s_0_m_axis": {
"interface_ports": [
- "mute_controller_0/m_axis",
- "axis_broadcaster_0/S_AXIS"
- ]
- },
- "axis_broadcaster_0_M01_AXIS": {
- "interface_ports": [
- "axis_broadcaster_0/M01_AXIS",
- "led_level_controller_0/s_axis"
+ "axis_dual_i2s_0/m_axis",
+ "moving_average_filte_0/s_axis"
]
},
"moving_average_filte_0_m_axis": {
@@ -1818,6 +1776,12 @@
"balance_controller_0/s_axis",
"moving_average_filte_0/m_axis"
]
+ },
+ "mute_controller_0_m_axis": {
+ "interface_ports": [
+ "mute_controller_0/m_axis",
+ "axis_broadcaster_0/S_AXIS"
+ ]
}
},
"nets": {
@@ -1837,14 +1801,14 @@
"axis_broadcaster_0/aclk",
"moving_average_filte_0/aclk",
"volume_controller_0/aclk",
- "LFO_0/aclk",
"balance_controller_0/aclk",
"effect_selector_0/aclk",
"led_level_controller_0/aclk",
"mute_controller_0/aclk",
"axi4stream_spi_master_0/aclk",
"axis_dual_i2s_0/aclk",
- "digilent_jstk2_0/aclk"
+ "digilent_jstk2_0/aclk",
+ "LFO_0/aclk"
]
},
"reset_1": {
@@ -1876,14 +1840,14 @@
"axis_broadcaster_0/aresetn",
"moving_average_filte_0/aresetn",
"volume_controller_0/aresetn",
- "LFO_0/aresetn",
"balance_controller_0/aresetn",
"effect_selector_0/aresetn",
"led_level_controller_0/aresetn",
"mute_controller_0/aresetn",
"axi4stream_spi_master_0/aresetn",
"axis_dual_i2s_0/aresetn",
- "digilent_jstk2_0/aresetn"
+ "digilent_jstk2_0/aresetn",
+ "LFO_0/aresetn"
]
},
"proc_sys_reset_1_peripheral_aresetn": {
diff --git a/LAB3/design/lab_3/lab_3.bda b/LAB3/design/lab_3/lab_3.bda
index 6485db2..93a605f 100644
--- a/LAB3/design/lab_3/lab_3.bda
+++ b/LAB3/design/lab_3/lab_3.bda
@@ -21,22 +21,22 @@
- lab_3
- BC
-
-
- 2
- lab_3
- VR
-
-
active
2
PM
-
+
+ lab_3
+ BC
+
+
+ 2
+ lab_3
+ VR
+
+
-
+
diff --git a/LAB3/src/LFO.vhd b/LAB3/src/LFO.vhd
index 34d810d..48d8fe8 100644
--- a/LAB3/src/LFO.vhd
+++ b/LAB3/src/LFO.vhd
@@ -35,33 +35,33 @@ END ENTITY LFO;
ARCHITECTURE Behavioral OF LFO IS
- CONSTANT LFO_COUNTER_BASE_PERIOD_NS : INTEGER := 100000;
+ CONSTANT LFO_COUNTER_BASE_PERIOD_US : INTEGER := 1000; -- 1ms
CONSTANT ADJUSTMENT_FACTOR : INTEGER := 90;
-
+ CONSTANT JSTK_CENTER_VALUE : INTEGER := 2 ** (JOYSTICK_LENGHT - 1);
+ constant LFO_COUNTER_BASE_CLK_CYCLES : INTEGER := LFO_COUNTER_BASE_PERIOD_US * 1000 / CLK_PERIOD_NS;
+
+ SIGNAL step_clk_cycles : INTEGER := LFO_COUNTER_BASE_CLK_CYCLES;
SIGNAL step_counter : INTEGER := 1;
- SIGNAL tri_counter : signed(CHANNEL_LENGHT - 1 DOWNTO 0) := (OTHERS => '0');
+ SIGNAL tri_counter : signed(TRIANGULAR_COUNTER_LENGHT - 1 DOWNTO 0) := (OTHERS => '0');
SIGNAL direction_up : STD_LOGIC := '1';
- SIGNAL lfo_tick : STD_LOGIC := '0';
+ SIGNAL lfo_product : STD_LOGIC_VECTOR(CHANNEL_LENGHT + TRIANGULAR_COUNTER_LENGHT - 1 DOWNTO 0) := (OTHERS => '0');
- SIGNAL lfo_period_int : INTEGER := LFO_COUNTER_BASE_PERIOD_NS;
- SIGNAL m_axis_tvalid_i : STD_LOGIC := '0';
- SIGNAL m_axis_tdata_i : STD_LOGIC_VECTOR(CHANNEL_LENGHT - 1 DOWNTO 0) := (OTHERS => '0');
- SIGNAL m_axis_tlast_i : STD_LOGIC := '0';
- SIGNAL s_axis_tready_i : STD_LOGIC := '1';
- SIGNAL temp : STD_LOGIC_VECTOR(CHANNEL_LENGHT + TRIANGULAR_COUNTER_LENGHT - 1 DOWNTO 0) := (OTHERS => '0');
+ SIGNAL trigger : STD_LOGIC := '0';
+
+ SIGNAL s_axis_tready_int : STD_LOGIC := '0';
+ SIGNAL m_axis_tvalid_int : STD_LOGIC := '0';
BEGIN
-- Output assignments
- s_axis_tready <= s_axis_tready_i;
- m_axis_tdata <= m_axis_tdata_i;
- m_axis_tvalid <= m_axis_tvalid_i;
- m_axis_tlast <= m_axis_tlast_i;
+ s_axis_tready <= s_axis_tready_int;
+ m_axis_tvalid <= m_axis_tvalid_int;
+ -- LFO period adjustment process
PROCESS (aclk)
BEGIN
IF rising_edge(aclk) THEN
- lfo_period_int <= LFO_COUNTER_BASE_PERIOD_NS - ADJUSTMENT_FACTOR * to_integer(unsigned(lfo_period));
+ step_clk_cycles <= LFO_COUNTER_BASE_CLK_CYCLES - ADJUSTMENT_FACTOR * to_integer(JSTK_CENTER_VALUE - unsigned(lfo_period));
END IF;
END PROCESS;
@@ -69,95 +69,96 @@ BEGIN
PROCESS (aclk)
BEGIN
IF rising_edge(aclk) THEN
+
IF aresetn = '0' THEN
step_counter <= 0;
tri_counter <= (OTHERS => '0');
direction_up <= '1';
- lfo_tick <= '0';
- ELSIF lfo_enable = '1' THEN
+ ELSE
- IF step_counter < lfo_period_int THEN
- step_counter <= step_counter + 1;
- lfo_tick <= '0';
+ IF lfo_enable = '1' THEN
- ELSE
- step_counter <= 0;
- lfo_tick <= '1';
+ IF step_counter < step_clk_cycles THEN
+ step_counter <= step_counter + 1;
- IF direction_up = '1' THEN
- IF tri_counter = 2 ** TRIANGULAR_COUNTER_LENGHT - 1 THEN
- direction_up <= '0';
- tri_counter <= tri_counter - 1;
- ELSE
- tri_counter <= tri_counter + 1;
- END IF;
ELSE
- IF tri_counter = 0 THEN
- direction_up <= '1';
- tri_counter <= tri_counter + 1;
+ step_counter <= 0;
+
+ IF direction_up = '1' THEN
+
+ IF tri_counter = 2 ** TRIANGULAR_COUNTER_LENGHT - 1 THEN
+ direction_up <= '0';
+ tri_counter <= tri_counter - 1;
+ ELSE
+ tri_counter <= tri_counter + 1;
+ END IF;
+
ELSE
- tri_counter <= tri_counter - 1;
+ IF tri_counter = 0 THEN
+ direction_up <= '1';
+ tri_counter <= tri_counter + 1;
+ ELSE
+ tri_counter <= tri_counter - 1;
+ END IF;
+
END IF;
+
END IF;
+
END IF;
- ELSE
- lfo_tick <= '0';
- direction_up <= '1';
- tri_counter <= (OTHERS => '0');
- step_counter <= 0;
-
END IF;
END IF;
-
+
END PROCESS;
+ -- Handshake logic for the AXIS interface
PROCESS (aclk)
BEGIN
IF rising_edge(aclk) THEN
- IF aresetn = '0' THEN
- temp <= (OTHERS => '0');
- ELSIF s_axis_tvalid = '1' AND m_axis_tready = '1' AND lfo_enable = '1' THEN
- temp <= STD_LOGIC_VECTOR(
- resize(
- signed(s_axis_tdata) * signed(resize(tri_counter, s_axis_tdata'length)),
- temp'length
- )
- );
- END IF;
- END IF;
- END PROCESS;
- PROCESS (aclk)
- BEGIN
- IF rising_edge(aclk) THEN
IF aresetn = '0' THEN
- m_axis_tvalid_i <= '0';
- m_axis_tdata_i <= (OTHERS => '0');
- m_axis_tlast_i <= '0';
+ s_axis_tready_int <= '0';
+ m_axis_tvalid_int <= '0';
+ m_axis_tdata <= (OTHERS => '0');
+ m_axis_tlast <= '0';
+
ELSE
- IF s_axis_tvalid = '1' AND m_axis_tready = '1' THEN
+ -- Set the ready signal for the slave interface
+ s_axis_tready_int <= m_axis_tready OR NOT m_axis_tvalid_int;
+
+ -- Clear valid flag when master interface is ready
+ IF m_axis_tready = '1' THEN
+ m_axis_tvalid_int <= '0';
+ END IF;
+
+ IF trigger = '1' AND (m_axis_tvalid_int = '0' OR m_axis_tready = '1') THEN
+ m_axis_tvalid_int <= '1';
+ m_axis_tlast <= s_axis_tlast;
+ m_axis_tdata <= lfo_product(CHANNEL_LENGHT + TRIANGULAR_COUNTER_LENGHT - 1 DOWNTO TRIANGULAR_COUNTER_LENGHT);
+
+ trigger <= '0';
+ END IF;
+
+ -- Handle input data
+ IF s_axis_tvalid = '1' AND s_axis_tready_int = '1' THEN
IF lfo_enable = '1' THEN
- m_axis_tdata_i <= temp(temp'high DOWNTO temp'high - (CHANNEL_LENGHT - 1));
+ lfo_product <= STD_LOGIC_VECTOR(
+ signed(s_axis_tdata) * tri_counter
+ );
ELSE
- m_axis_tdata_i <= s_axis_tdata;
+ lfo_product <= s_axis_tdata;
END IF;
- s_axis_tready_i <= '0';
- m_axis_tvalid_i <= '1';
- m_axis_tlast_i <= s_axis_tlast;
- END IF;
- IF m_axis_tvalid_i = '1' THEN
- IF m_axis_tready = '0' THEN
- s_axis_tready_i <= '0';
- ELSE
- s_axis_tready_i <= '1';
- END IF;
- m_axis_tvalid_i <= '0';
+
+ trigger <= '1';
END IF;
+
END IF;
+
END IF;
+
END PROCESS;
END ARCHITECTURE Behavioral;
\ No newline at end of file
diff --git a/LAB3/vivado/lab3/lab3.xpr b/LAB3/vivado/lab3/lab3.xpr
index db3a47d..0736966 100644
--- a/LAB3/vivado/lab3/lab3.xpr
+++ b/LAB3/vivado/lab3/lab3.xpr
@@ -77,12 +77,6 @@
-
-
-
-
-
-
@@ -95,6 +89,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -143,6 +149,12 @@
+
+
+
+
+
+
@@ -156,13 +168,6 @@
-
-
-
-
-
-
-
@@ -170,13 +175,6 @@
-
-
-
-
-
-
-