FPGA BRAM working
This commit is contained in:
parent
900c0e292f
commit
5d1c7c4d51
15826
Core/Inc/User/fpga_bin.h
15826
Core/Inc/User/fpga_bin.h
File diff suppressed because it is too large
Load Diff
@ -135,10 +135,14 @@ void Error_Handler(void);
|
||||
#define FSMC_D2_GPIO_Port GPIOD
|
||||
#define FSMC_D3_Pin GPIO_PIN_1
|
||||
#define FSMC_D3_GPIO_Port GPIOD
|
||||
#define FSMC_CLK_Pin GPIO_PIN_3
|
||||
#define FSMC_CLK_GPIO_Port GPIOD
|
||||
#define FSMC_NOE_Pin GPIO_PIN_4
|
||||
#define FSMC_NOE_GPIO_Port GPIOD
|
||||
#define FSMC_NWE_Pin GPIO_PIN_5
|
||||
#define FSMC_NWE_GPIO_Port GPIOD
|
||||
#define FSMC_NWAIT_Pin GPIO_PIN_6
|
||||
#define FSMC_NWAIT_GPIO_Port GPIOD
|
||||
#define FSMC_NE1_Pin GPIO_PIN_7
|
||||
#define FSMC_NE1_GPIO_Port GPIOD
|
||||
#define EEM_POWER_SW_Pin GPIO_PIN_6
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "user_main.h"
|
||||
|
||||
#define ADC_SAMPLE_NUM 100
|
||||
#define ADC_SAMPLE_NUM 16384
|
||||
|
||||
uint8_t fsmc_read_buf, fsmc_write_buf;
|
||||
int8_t adc_result[ADC_SAMPLE_NUM];
|
||||
@ -27,8 +27,9 @@ void user_loop()
|
||||
fsmc_write_buf = (dio_io & 0x01) | ((dio_ch & 0x03) << 1) | 0x10;
|
||||
fsmc_write(fsmc_write_buf, 0);
|
||||
}
|
||||
fsmc_read(0xffff, (uint8_t*)&fsmc_read_buf);
|
||||
if (fsmc_read_buf & 0x02)
|
||||
// fsmc_read(0xffff, (uint8_t*)&fsmc_read_buf);
|
||||
// if (fsmc_read_buf & 0x02)
|
||||
if (HAL_GPIO_ReadPin(FSMC_NWAIT_GPIO_Port, FSMC_NWAIT_Pin) == GPIO_PIN_SET)
|
||||
{
|
||||
fsmc_write_buf = (dio_io & 0x01) | ((dio_ch & 0x03) << 1);
|
||||
fsmc_write(fsmc_write_buf, 0);
|
||||
|
@ -172,6 +172,12 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(SPI_FPGA_CS_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PDPin PDPin */
|
||||
GPIO_InitStruct.Pin = FSMC_CLK_Pin|FSMC_NWAIT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = EEM_POWER_SW_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
|
69
FPGA/top.v
69
FPGA/top.v
@ -1,44 +1,25 @@
|
||||
module top (
|
||||
CLK_25M,
|
||||
LED,
|
||||
KEY,
|
||||
DIO_OUT,
|
||||
DIO_IO_SEL,
|
||||
DIO_CH_SEL,
|
||||
ADC_CLK,
|
||||
ADC_DAT,
|
||||
FSMC_CLK,
|
||||
FSMC_ADD,
|
||||
FSMC_DAT,
|
||||
FSMC_NL,
|
||||
FSMC_NWAIT,
|
||||
FSMC_NOE,
|
||||
FSMC_NWE,
|
||||
FSMC_NBL,
|
||||
FSMC_NE1
|
||||
);
|
||||
input CLK_25M,
|
||||
input KEY,
|
||||
output LED,
|
||||
|
||||
/* I/O */
|
||||
input CLK_25M;
|
||||
input KEY;
|
||||
output LED;
|
||||
input FSMC_NL,
|
||||
input FSMC_NOE,
|
||||
input FSMC_NWE,
|
||||
input FSMC_NE1,
|
||||
input [15:0]FSMC_ADD,
|
||||
inout [7:0]FSMC_DAT,
|
||||
input [1:0]FSMC_NBL,
|
||||
inout FSMC_CLK,
|
||||
inout FSMC_NWAIT,
|
||||
|
||||
input FSMC_NL;
|
||||
input FSMC_NOE;
|
||||
input FSMC_NWE;
|
||||
input FSMC_NE1;
|
||||
input [15:0]FSMC_ADD;
|
||||
inout [7:0]FSMC_DAT;
|
||||
input [1:0]FSMC_NBL;
|
||||
input FSMC_CLK;
|
||||
input FSMC_NWAIT;
|
||||
output ADC_CLK,
|
||||
input [7:0]ADC_DAT,
|
||||
|
||||
output ADC_CLK;
|
||||
input [7:0]ADC_DAT;
|
||||
|
||||
output DIO_OUT;
|
||||
output DIO_IO_SEL;
|
||||
output [2:0]DIO_CH_SEL;
|
||||
output DIO_OUT,
|
||||
output DIO_IO_SEL,
|
||||
output [2:0]DIO_CH_SEL,
|
||||
);
|
||||
|
||||
/* Counter register */
|
||||
reg [31:0] counter = 32'b0;
|
||||
@ -67,11 +48,11 @@ module top (
|
||||
.BYPASS(1'b0)
|
||||
);
|
||||
|
||||
|
||||
parameter ADC_RAM_DEPTH = 16384;
|
||||
/* high-speed ADC */
|
||||
assign ADC_CLK = CLK_50M;
|
||||
reg [7:0] adc_buf = 8'b0;
|
||||
reg [7:0] adc_ram [100];
|
||||
reg [7:0] adc_ram [0:ADC_RAM_DEPTH-1];
|
||||
reg [15:0] ram_pointer = 0;
|
||||
reg [7:0] adc_status = 8'h00; //0:idle or sampling; 1: data available
|
||||
always @ (posedge ADC_CLK) begin
|
||||
@ -79,7 +60,7 @@ module top (
|
||||
adc_buf = ADC_DAT;
|
||||
adc_buf[7] = ~adc_buf[7];
|
||||
adc_ram[ram_pointer] = adc_buf;
|
||||
if (ram_pointer < 100) begin
|
||||
if (ram_pointer < ADC_RAM_DEPTH) begin
|
||||
adc_status[1] = 1'b0;
|
||||
ram_pointer++;
|
||||
end
|
||||
@ -95,9 +76,9 @@ module top (
|
||||
|
||||
wire FSMC_RE = ~FSMC_NOE & ~FSMC_NE1;
|
||||
always @ (posedge FSMC_RE) begin //read from FPGA
|
||||
if (FSMC_ADD == 16'hffff)
|
||||
FSMC_DAT <= adc_status;
|
||||
else
|
||||
// if (FSMC_ADD == 16'hffff)
|
||||
// FSMC_DAT <= adc_status;
|
||||
// else
|
||||
FSMC_DAT <= adc_ram[FSMC_ADD];
|
||||
end
|
||||
|
||||
@ -111,6 +92,8 @@ module top (
|
||||
end
|
||||
|
||||
// assign FSMC_DAT = FSMC_RE ? fsmc_buf : 8'hzz;
|
||||
assign FSMC_CLK = adc_status[0];
|
||||
assign FSMC_NWAIT = adc_status[1];
|
||||
assign LED = adc_status[1];
|
||||
|
||||
endmodule
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
##########################################################################################################################
|
||||
# File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Sun Jan 09 16:58:14 HKT 2022]
|
||||
# File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Sat Jan 15 15:39:31 HKT 2022]
|
||||
##########################################################################################################################
|
||||
|
||||
# ------------------------------------------------
|
||||
|
@ -1,30 +1,32 @@
|
||||
|
||||
OpenDocument="fpga.c", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/Core/Src/User/fpga.c", Line=43
|
||||
OpenDocument="main.c", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/Core/Src/main.c", Line=64
|
||||
OpenDocument="main.c", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/Core/Src/main.c", Line=63
|
||||
OpenDocument="stm32f1xx_hal.c", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c", Line=372
|
||||
OpenDocument="stm32f1xx_it.c", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/Core/Src/stm32f1xx_it.c", Line=79
|
||||
OpenDocument="startup_stm32f103xg.s", FilePath="/home/geekzjk/Desktop/Syrostan-MCU-C/startup_stm32f103xg.s", Line=56
|
||||
OpenToolbar="Debug", Floating=0, x=0, y=0
|
||||
OpenWindow="Registers 1", DockArea=RIGHT, x=0, y=0, w=300, h=629, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, FilteredItems=[], RefreshRate=1
|
||||
OpenWindow="Memory 1", DockArea=BOTTOM, x=3, y=0, w=162, h=318, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, EditorAddress=0xFC
|
||||
OpenWindow="Watched Data 1", DockArea=LEFT, x=0, y=1, w=484, h=363, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
|
||||
OpenWindow="Functions", DockArea=LEFT, x=0, y=0, w=484, h=265, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
|
||||
OpenWindow="Watched Data 1", DockArea=LEFT, x=0, y=1, w=484, h=520, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
|
||||
OpenWindow="Functions", DockArea=LEFT, x=0, y=0, w=484, h=108, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
|
||||
OpenWindow="Data Sampling", DockArea=BOTTOM, x=1, y=0, w=470, h=318, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, VisibleTab=0, UniformSampleSpacing=0
|
||||
OpenWindow="Timeline", DockArea=BOTTOM, x=2, y=0, w=916, h=318, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=1, CodePaneShown=1, PinCursor="Cursor Movable", TimePerDiv="50 ms / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="697;0", PowerGraphDrawAsPoints=0, PowerGraphLegendShown=1, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="733;0", CodeGraphLegendShown=1, CodeGraphLegendPosition="749;0"
|
||||
OpenWindow="Timeline", DockArea=BOTTOM, x=2, y=0, w=916, h=318, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=1, CodePaneShown=1, PinCursor="Cursor Movable", TimePerDiv="50 ms / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="697;0", PowerGraphDrawAsPoints=0, PowerGraphLegendShown=1, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="734;1", CodeGraphLegendShown=1, CodeGraphLegendPosition="750;0"
|
||||
OpenWindow="Console", DockArea=BOTTOM, x=0, y=0, w=369, h=318, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
|
||||
TableHeader="Functions", SortCol="Name", SortOrder="DESCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[1183;100;100;100;203]
|
||||
TableHeader="Data Sampling Table", SortCol="Index", SortOrder="ASCENDING", VisibleCols=["Index";"Time"], ColWidths=[100;100]
|
||||
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[100;100;100;100;100;100;100;100;100]
|
||||
TableHeader="Power Sampling", SortCol="Index", SortOrder="ASCENDING", VisibleCols=["Index";"Time";"Ch 0"], ColWidths=[100;100;100]
|
||||
TableHeader="Registers 1", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[100;105;259]
|
||||
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[133;144;100;100]
|
||||
TableHeader="RegisterSelectionDialog", SortCol="None", SortOrder="ASCENDING", VisibleCols=[], ColWidths=[]
|
||||
TableHeader="TargetExceptionDialog", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Address";"Description"], ColWidths=[200;100;100;358]
|
||||
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[133;144;100;107]
|
||||
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time"], ColWidths=[100;100]
|
||||
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[100;100;100;100;100;100;100;100;100]
|
||||
WatchedExpression="spi_test_data", RefreshRate=5, DisplayFormat=DISPLAY_FORMAT_HEX, Window=Watched Data 1
|
||||
WatchedExpression="enc_mac_address", RefreshRate=5, DisplayFormat=DISPLAY_FORMAT_HEX, Window=Watched Data 1
|
||||
WatchedExpression="voltages", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="eem_current", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="fsmc_buf", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="i", RefreshRate=5, DisplayFormat=DISPLAY_FORMAT_BINARY, Window=Watched Data 1
|
||||
WatchedExpression="dio_ch", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="dio_io", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="fsmc_read_buf", RefreshRate=5, DisplayFormat=DISPLAY_FORMAT_BINARY, Window=Watched Data 1
|
||||
WatchedExpression="fsmc_write_buf", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="adc_sample", RefreshRate=5, Window=Watched Data 1
|
||||
WatchedExpression="adc_result", RefreshRate=5, Window=Watched Data 1
|
@ -122,22 +122,24 @@ Mcu.Pin57=PC11
|
||||
Mcu.Pin58=PD0
|
||||
Mcu.Pin59=PD1
|
||||
Mcu.Pin6=OSC_IN
|
||||
Mcu.Pin60=PD4
|
||||
Mcu.Pin61=PD5
|
||||
Mcu.Pin62=PD7
|
||||
Mcu.Pin63=PB3
|
||||
Mcu.Pin64=PB4
|
||||
Mcu.Pin65=PB5
|
||||
Mcu.Pin66=PB6
|
||||
Mcu.Pin67=PB8
|
||||
Mcu.Pin68=PB9
|
||||
Mcu.Pin69=VP_SYS_VS_Systick
|
||||
Mcu.Pin60=PD3
|
||||
Mcu.Pin61=PD4
|
||||
Mcu.Pin62=PD5
|
||||
Mcu.Pin63=PD6
|
||||
Mcu.Pin64=PD7
|
||||
Mcu.Pin65=PB3
|
||||
Mcu.Pin66=PB4
|
||||
Mcu.Pin67=PB5
|
||||
Mcu.Pin68=PB6
|
||||
Mcu.Pin69=PB8
|
||||
Mcu.Pin7=OSC_OUT
|
||||
Mcu.Pin70=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin71=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin70=PB9
|
||||
Mcu.Pin71=VP_SYS_VS_Systick
|
||||
Mcu.Pin72=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin73=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin8=PC0
|
||||
Mcu.Pin9=PC1
|
||||
Mcu.PinsNb=72
|
||||
Mcu.PinsNb=74
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103VFTx
|
||||
@ -336,6 +338,11 @@ PD15.GPIOParameters=GPIO_Label
|
||||
PD15.GPIO_Label=FSMC_D1
|
||||
PD15.Locked=true
|
||||
PD15.Signal=GPIO_Output
|
||||
PD3.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PD3.GPIO_Label=FSMC_CLK
|
||||
PD3.GPIO_PuPd=GPIO_PULLUP
|
||||
PD3.Locked=true
|
||||
PD3.Signal=GPIO_Input
|
||||
PD4.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
|
||||
PD4.GPIO_Label=FSMC_NOE
|
||||
PD4.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
|
||||
@ -352,6 +359,11 @@ PD5.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PD5.Locked=true
|
||||
PD5.PinState=GPIO_PIN_SET
|
||||
PD5.Signal=GPIO_Output
|
||||
PD6.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PD6.GPIO_Label=FSMC_NWAIT
|
||||
PD6.GPIO_PuPd=GPIO_PULLUP
|
||||
PD6.Locked=true
|
||||
PD6.Signal=GPIO_Input
|
||||
PD7.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
|
||||
PD7.GPIO_Label=FSMC_NE1
|
||||
PD7.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
|
||||
|
Loading…
Reference in New Issue
Block a user