Skip to content

Instantly share code, notes, and snippets.

@pome1618
pome1618 / main.c
Last active December 17, 2018 17:29
main.c
/*
* File: main.c
* Author: pome
*
* Created on 2018/12/14, 2:28
*/
#include <stdio.h>
#include <stdlib.h>
#include "DigiKeyboard.h"
#define SWITCH_NUM 2
#define RIGHT 0
#define LEFT 1
#define KEY_RIGHT KEY_A
#define KEY_LEFT KEY_B
#define KEY_MOD_RIGHT NULL
void APP_Tasks ( void )
{
/* Check the application's current state. */
switch ( appData.state )
{
/* Application's initial state. */
case APP_STATE_INIT:
{
bool appInitialized = true;
void delay_ms(int ms){
int i,j;
int n=SYS_CLK_FREQ/1000/3;
for(i=0;i<ms;i++){
for(j=0;j<n;j++){
Nop();
}
}
}
(12:55) gp > \r tester_ml.gp
k : 12
: [1, 1, 0, 0]
base point P : [Mod(58745, 65521), 1]
before R0 : [0]
before R1 : [Mod(58745, 65521), 1]
R0<=R1+R0
R1<=2*R1
after R0 : [Mod(58745, 65521), 1]
module subtractor(
input [N-1:0] a,b,
output [N-1:0] out
);
parameter N = 16;
parameter p = 65521;
logic signed [N:0] sub;
module multiplier(
input [N-1:0] a,b,
output [N-1:0] out
);
parameter N = 16;
parameter p = 65521;
always begin
out = (a*b)%p;
`define DEBUG
module ml(
input clk,
input logic [N-1:0] alpha,X,Z,
input logic [N-1:0] k,
output logic [N-1:0] Xk,Zk
`ifdef DEBUG
,output wire [N-1:0] o_pointer,o_R0_0,o_R0_1,o_R1_0,o_R1_1,o_Pm_0,o_Pm_1,o_Pn_0,o_Pn_1,o_Po_0,o_Po_1,
output wire [3:0] o_count,
module memory_d(
input clk,rst,
input [2:0] in_sel[2:0],
input [2:0] out_sel[5:0],
input [N-1:0] alpha,Xn,Zn,
input [N-1:0] in[2:0],
output [N-1:0] out[5:0]
);
parameter N = 16;
module memory_a(
input wire clk,rst,
input logic [1:0] in_sel[2:0],
input logic [3:0] out_sel[5:0],
input logic [N-1:0] X1,Z1,Xm,Zm,Xn,Zn,
input logic [N-1:0] in[2:0],
output logic [N-1:0] out[5:0]
);
parameter N = 16;