Skip to content

Instantly share code, notes, and snippets.

@yodalee
yodalee / fastfib.c
Created February 11, 2019 17:25
Fast Fibonacci and Fomula Solution
// file: fastfib.c
// compile with gcc -lgmp fastfib.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <gmp.h>
#include <ctype.h>
@yodalee
yodalee / randomgen.rs
Created June 23, 2020 14:33
Random number generator in Rust with stated structure
use std::time::{SystemTime, UNIX_EPOCH};
const SEED_MAX:u64 = 9999997;
struct RandomGen {
seed: u64
}
impl RandomGen {
pub fn new(seed: u64) -> Self {
#!/usr/bin/env python
PAGES = 180
DAYS = 14
memo = {}
def search(page: int, days: int) -> int:
if (page, days) in memo:
return memo[(page, days)]
module FLOLAC22 where
import Data.List
-- This exercise covers the first 6 and the 8th chapters of "Learn You a Haskell for Great Good!"
-- Chapter 1 - http://learnyouahaskell.com/introduction
-- Chapter 2 - http://learnyouahaskell.com/starting-out
-- Chapter 3 - http://learnyouahaskell.com/types-and-typeclasses
-- Chapter 4 - http://learnyouahaskell.com/syntax-in-functions
@yodalee
yodalee / CMakeLists.txt
Created January 30, 2023 15:29
Verilator cmake does not generate right configuration with system-verilog package
cmake_minimum_required(VERSION 3.16)
project(verilog)
find_package(verilator HINTS $ENV{VERILATOR_ROOT})
set(OUT Vmain)
add_executable(${OUT} main.cpp)
verilate(${OUT} TRACE_FST SOURCES out.sv pkg.sv)
typedef struct {
logic [255:0] msg;
logic [255:0] key;
logic [255:0] modulus;
} StructType;
module TestMod (
input logic clk,
StructType in
);
@yodalee
yodalee / error.log
Created February 23, 2023 14:52
Compiler Error of Generated code.
In file included from Vtest__ALL.cpp:6:
Vtest___024unit__DepSet_h9b08f7a8__0.cpp: In function 'std::string VL_TO_STRING(const Vtest_StructType__struct1&)':
Vtest___024unit__DepSet_h9b08f7a8__0.cpp:13:42: error: invalid user-defined conversion from 'const VlWide<8>' to 'int' [-fpermissive]
13 | out += "'{msg:" + VL_TO_STRING_W(obj.msg);
| ~~~~^~~
In file included from /home/yodalee/local/share/verilator/include/verilated.h:930,
from Vtest.h:11,
from Vtest.cpp:4,
from Vtest__ALL.cpp:3:
/home/yodalee/local/share/verilator/include/verilated_types.h:217:5: note: candidate is: 'VlWide<T_Words>::operator WDataInP() const [with long unsigned int T_Words = 8; WDataInP = const unsigned int*]' (near match)